openapi: 3.1.0
info:
  title: BusinessWire.Ng Content & Automated Desk API
  version: 1.0.0
  description: >
    RESTful API and automated desk ingestion pipeline powering BusinessWire.Ng — 
    Nigeria's high-velocity, video-first, AI-enabled business news platform.
    Features automated desk reframing, contributor review queues, LiveTV syndication,
    PostgreSQL persistence, Model Context Protocol (MCP) server integration, and automated rate limiting.

servers:
  - url: http://127.0.0.1:8000
    description: Local Development Server
  - url: https://api.businesswire.ng/v1
    description: Production Server (v1)
  - url: https://staging-api.businesswire.ng/v1
    description: Staging Sandbox

tags:
  - name: Articles & Ingestion Desk
    description: Endpoints for querying published articles across editorial verticals and ingesting automated desk / reporter stories.
    externalDocs:
      description: Editorial Framework & Guidelines
      url: https://businesswire.ng/editorial-policy
  - name: Guest Columnist Portal
    description: Submission and review pipelines for external columnists, thought leaders, and market analysts.
  - name: LiveTV & Video Syndication
    description: Video programs (Morning Brief, Evening Curated, Trending Business Angle) and multimedia assets.
  - name: System & Governance
    description: Operational health checks, database connectivity verification, and version diagnostics.
  - name: Advertising & Campaigns Engine
    description: Commercial monetization, pop-up interstitial targeting, behavioral triggers, and client flight tracking.
  - name: MCP & AI Integration
    description: Model Context Protocol (MCP 2.x) tools, resources, and prompt templates for autonomous AI assistants.

paths:
  /articles:
    get:
      tags:
        - Articles & Ingestion Desk
      summary: List published articles
      description: Retrieve paginated published articles filterable by section, source type, and tags with numbered archive pagination (12-15 items per page). Rate limited to 120 req/min.
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for numbered archive pagination.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 12
            minimum: 1
            maximum: 50
          description: Articles per page.
        - name: section
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/SectionEnum'
          description: Filter by editorial section vertical.
        - name: tag
          in: query
          required: false
          schema:
            type: string
          description: Filter by tag keyword.
        - name: source_type
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/SourceTypeEnum'
          description: Filter by ingestion source type.
      responses:
        '200':
          description: Paginated list of articles.
          content:
            application/json:
              schema:
                type: object
                properties:
                  pagination:
                    $ref: '#/components/schemas/PaginationMeta'
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Article'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

    post:
      tags:
        - Articles & Ingestion Desk
      summary: Ingest / Publish an article
      description: Ingests automated desk reframed stories or files original reporter articles into the BusinessWire CMS pipeline. Rate limited to 30 req/min.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ArticleCreateRequest'
      responses:
        '201':
          description: Article successfully created and persisted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Article'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

  /articles/{id_or_slug}:
    get:
      tags:
        - Articles & Ingestion Desk
      summary: Get article by ID or slug
      description: Retrieve comprehensive article content, complete with the 5-point editorial framework, author details, and source attributions. Rate limited to 180 req/min.
      parameters:
        - name: id_or_slug
          in: path
          required: true
          schema:
            type: string
          description: Unique article UUID or SEO slug.
      responses:
        '200':
          description: Detailed article object with editorial framework.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ArticleDetail'
        '404':
          $ref: '#/components/responses/404NotFound'
        '429':
          $ref: '#/components/responses/429TooManyRequests'
    delete:
      tags:
        - Articles & Ingestion Desk
      summary: Delete an article
      description: Permanently removes an article by UUID or SEO slug from PostgreSQL.
      parameters:
        - name: id_or_slug
          in: path
          required: true
          schema:
            type: string
          description: Unique article UUID or SEO slug.
      responses:
        '200':
          description: Article successfully deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  message:
                    type: string
                    example: Article deleted successfully
        '404':
          $ref: '#/components/responses/404NotFound'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

  /guest-columns/submit:
    post:
      tags:
        - Guest Columnist Portal
      summary: Submit a guest column pitch or draft
      description: Front-end submission routing to the pending editorial review queue with mandatory conflict of interest declaration. Protected against spam with strict rate limiting (10 req/min).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GuestColumnSubmission'
      responses:
        '202':
          description: Pitch/Draft accepted for editorial review.
          content:
            application/json:
              schema:
                type: object
                properties:
                  submission_id:
                    type: string
                    format: uuid
                  status:
                    type: string
                    example: "pending_review"
                  message:
                    type: string
                    example: "Submission received. Routed for Senior Editorial Management review."
        '400':
          $ref: '#/components/responses/400BadRequest'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

  /guest-columns:
    get:
      tags:
        - Guest Columnist Portal
      summary: List guest column submissions
      description: Returns editorial queue of submitted pitches and drafts from external contributors.
      responses:
        '200':
          description: List of guest column submissions.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GuestColumnSubmissionResponse'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

  /guest-columns/{id}:
    delete:
      tags:
        - Guest Columnist Portal
      summary: Delete a guest column submission
      description: Permanently removes a guest column submission by UUID from PostgreSQL.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Unique submission UUID.
      responses:
        '200':
          description: Submission deleted successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  message:
                    type: string
                    example: Guest column submission deleted successfully
        '404':
          $ref: '#/components/responses/404NotFound'

  /livetv/videos:
    get:
      tags:
        - LiveTV & Video Syndication
      summary: List video hub archive
      description: Numbered paginated endpoint for LiveTV video programs and clips (Morning Brief, Evening Curated, Trending Business Angle). Rate limited to 120 req/min.
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            default: 1
            minimum: 1
        - name: program_type
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/VideoProgramEnum'
      responses:
        '200':
          description: Paginated video list.
          content:
            application/json:
              schema:
                type: object
                properties:
                  pagination:
                    $ref: '#/components/schemas/PaginationMeta'
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/LiveTVVideo'
        '429':
          $ref: '#/components/responses/429TooManyRequests'
    post:
      tags:
        - LiveTV & Video Syndication
      summary: Ingest / Publish a LiveTV video
      description: Creates and persists a new video program or clip (Morning Brief, Evening Curated, Trending Business Angle) to the media archive and PostgreSQL.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LiveTVVideoCreate'
      responses:
        '201':
          description: Video successfully registered and published.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LiveTVVideo'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

  /livetv/videos/{id}:
    delete:
      tags:
        - LiveTV & Video Syndication
      summary: Delete a LiveTV video
      description: Permanently removes a video entry by UUID from PostgreSQL and LiveTV syndication.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Video UUID.
      responses:
        '200':
          description: Video successfully deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  message:
                    type: string
                    example: LiveTV video deleted successfully
        '404':
          $ref: '#/components/responses/404NotFound'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

  /adverts/popups:
    get:
      tags:
        - Advertising & Campaigns Engine
      summary: List all pop-up adverts for Management Console
      description: Returns all configured commercial interstitials, targeting rules, behavioral triggers and conversion counters.
      responses:
        '200':
          description: List of pop-up adverts.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PopUpAdvertResponse'
        '429':
          $ref: '#/components/responses/429TooManyRequests'
    post:
      tags:
        - Advertising & Campaigns Engine
      summary: Create or configure a new pop-up advert
      description: Creates a new commercial interstitial modal with behavioral triggers (delay, scroll depth, exit-intent) and section targeting.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PopUpAdvertCreate'
      responses:
        '201':
          description: Pop-up advert created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PopUpAdvertResponse'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

  /adverts/popups/{id}:
    delete:
      tags:
        - Advertising & Campaigns Engine
      summary: Delete a pop-up advert
      description: Permanently removes a pop-up interstitial advert by UUID from PostgreSQL.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Pop-up UUID.
      responses:
        '200':
          description: Pop-up deleted successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  message:
                    type: string
                    example: Pop-up advert deleted successfully
        '404':
          $ref: '#/components/responses/404NotFound'

  /adverts/popups/{id}/toggle:
    patch:
      tags:
        - Advertising & Campaigns Engine
      summary: Toggle pop-up advert active state
      description: Quickly toggle between active and paused states for an interstitial flight.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Pop-up UUID.
      responses:
        '200':
          description: Status toggled successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  id:
                    type: string
                  is_active:
                    type: boolean

  /adverts/popups/active:
    get:
      tags:
        - Advertising & Campaigns Engine
      summary: Get active pop-up advert for readers
      description: Returns the currently active commercial interstitial advert for the requested editorial section, complete with behavioral triggers (delay, scroll depth, exit-intent).
      parameters:
        - name: section
          in: query
          required: false
          schema:
            type: string
          description: Editorial section name (e.g., news, real-estate-market, brands-marketing)
      responses:
        '200':
          description: Active pop-up advert details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PopUpAdvertResponse'
        '429':
          $ref: '#/components/responses/429TooManyRequests'

  /adverts/campaigns:
    get:
      tags:
        - Advertising & Campaigns Engine
      summary: List commercial campaigns
      description: Returns active or scheduled corporate advertising flights with budgets and performance.
      parameters:
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum: [active, scheduled, paused, completed]
      responses:
        '200':
          description: List of advertising campaigns.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AdCampaignResponse'
    post:
      tags:
        - Advertising & Campaigns Engine
      summary: Create a new client ad flight / campaign
      description: Creates a corporate client flight record with budget (NGN), target impressions, flight dates, and contact email.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdCampaignCreate'
      responses:
        '201':
          description: Campaign flight created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdCampaignResponse'
        '400':
          $ref: '#/components/responses/400BadRequest'

  /adverts/campaigns/{id}:
    delete:
      tags:
        - Advertising & Campaigns Engine
      summary: Delete an advertising campaign
      description: Permanently removes a commercial campaign flight by UUID from PostgreSQL.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Campaign UUID.
      responses:
        '200':
          description: Campaign flight deleted successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  message:
                    type: string
                    example: Campaign deleted successfully
        '404':
          $ref: '#/components/responses/404NotFound'

  /adverts/banners:
    get:
      tags:
        - Advertising & Campaigns Engine
      summary: List display banners
      description: Returns display banners filterable by ad slot (leaderboard, sidebar, inline, footer).
      parameters:
        - name: slot
          in: query
          required: false
          schema:
            type: string
          description: Ad slot name (leaderboard, sidebar, inline, footer)
      responses:
        '200':
          description: List of display banners.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DisplayBannerResponse'
    post:
      tags:
        - Advertising & Campaigns Engine
      summary: Create a display banner
      description: Registers a display ad banner creative, slot dimensions, and target redirect URL.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DisplayBannerCreate'
      responses:
        '201':
          description: Display banner registered successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DisplayBannerResponse'

  /adverts/banners/{id}:
    delete:
      tags:
        - Advertising & Campaigns Engine
      summary: Delete a display banner
      description: Permanently removes a display banner creative by UUID from PostgreSQL.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Banner UUID.
      responses:
        '200':
          description: Banner deleted successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  message:
                    type: string
                    example: Display banner deleted successfully
        '404':
          $ref: '#/components/responses/404NotFound'

  /adverts/settings:
    get:
      tags:
        - Advertising & Campaigns Engine
      summary: Get runtime advertising configuration
      description: Returns global rotational sidebar timer and pacing rules.
      responses:
        '200':
          description: Runtime advertising settings.
          content:
            application/json:
              schema:
                type: object
                properties:
                  rotational_timer_seconds:
                    type: integer
                    example: 8
    put:
      tags:
        - Advertising & Campaigns Engine
      summary: Update runtime advertising configuration
      description: Updates global rotational timer duration for sidebar display banners.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - rotational_timer_seconds
              properties:
                rotational_timer_seconds:
                  type: integer
                  minimum: 2
                  maximum: 120
                  example: 8
      responses:
        '200':
          description: Settings updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  rotational_timer_seconds:
                    type: integer

  /health:
    get:
      tags:
        - System & Governance
      summary: System health & DB connectivity status
      description: Check the operational uptime, release version, and PostgreSQL database connection status. Exempt from rate limits.
      responses:
        '200':
          description: Service health diagnostics.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthResponse'

  /mcp/info:
    get:
      tags:
        - MCP & AI Integration
      summary: Model Context Protocol (MCP) Manifest
      description: Returns discovery metadata for MCP clients (Claude, Cursor, Antigravity) detailing available tools, resources, prompt templates, and Keycloak OAuth2 authentication requirements.
      responses:
        '200':
          description: MCP server discovery and security manifest.
          content:
            application/json:
              schema:
                type: object
                properties:
                  mcp_server:
                    type: string
                    example: "BusinessWire-MCP"
                  version:
                    type: string
                    example: "1.0.0"
                  protocol:
                    type: string
                    example: "Model Context Protocol (MCP) v2.1.1 (Spec 2026-07-28)"
                  security:
                    type: object
                    properties:
                      type:
                        type: string
                        example: "OAuth2 / OpenID Connect Bearer Token"
                      enforced:
                        type: boolean
                        example: true
                      provider:
                        type: string
                        example: "Keycloak IAM"
                      realm:
                        type: string
                        example: "master"
                      client_id:
                        type: string
                        example: "bw-client"
                      token_endpoint:
                        type: string
                        example: "http://localhost:8080/realms/master/protocol/openid-connect/token"
                  transports:
                    type: object
                    properties:
                      sse_endpoint:
                        type: string
                        example: "/mcp/sse"
                      message_endpoint:
                        type: string
                        example: "/mcp/messages/"
                  capabilities:
                    type: object
                    properties:
                      tools:
                        type: array
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                            description:
                              type: string
                      resources:
                        type: array
                        items:
                          type: object
                      prompts:
                        type: array
                        items:
                          type: object

  /mcp/sse:
    get:
      tags:
        - MCP & AI Integration
      summary: MCP Server-Sent Events (SSE) Stream
      description: >
        Real-time SSE streaming connection for AI assistants and MCP clients.
        Requires Keycloak Bearer Token via Authorization: Bearer <token> or query parameter ?token=<token>.
      security:
        - KeycloakBearer: []
        - KeycloakOAuth2: [openid, profile]
      responses:
        '200':
          description: Active Server-Sent Events stream established.
          content:
            text/event-stream:
              schema:
                type: string
        '401':
          description: Unauthorized. Missing or invalid Keycloak Bearer token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: "unauthorized"
                  message:
                    type: string
                    example: "Keycloak Bearer token required for MCP endpoints."


components:
  schemas:
    SectionEnum:
      type: string
      enum:
        - news
        - brands-marketing
        - culture-commerce
        - diaspora-wire
        - real-estate-market
        - real-estate
        - entertainments
        - entertainment
        - sports
        - opinion
      description: Canonical editorial verticals for BusinessWire.Ng.

    SourceTypeEnum:
      type: string
      enum:
        - automated_desk
        - reporter
        - guest_column
      description: Ingestion origin and classification.

    VideoProgramEnum:
      type: string
      enum:
        - morning_brief
        - evening_curated
        - trending_business_angle
        - businesswire_ng_live
      description: Broadcast format for LiveTV syndication.

    PaginationMeta:
      type: object
      properties:
        current_page:
          type: integer
          example: 1
        total_pages:
          type: integer
          example: 14
        items_per_page:
          type: integer
          example: 12
        total_items:
          type: integer
          example: 168

    Article:
      type: object
      required:
        - id
        - title
        - slug
        - section
        - source_type
        - published_at
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
          example: "Your Loan Just Got Pricier: What the CBN's New 27.5% Rate Means for You"
        slug:
          type: string
          example: "cbn-interest-rate-27-5-impact"
        summary:
          type: string
          example: "Analysis of the central bank rate hike and its immediate impact on borrower costs."
        section:
          $ref: '#/components/schemas/SectionEnum'
        tags:
          type: array
          items:
            type: string
          example: ["CBN", "Interest Rates", "Banking", "Inflation"]
        source_type:
          $ref: '#/components/schemas/SourceTypeEnum'
        featured_image_url:
          type: string
          format: uri
        published_at:
          type: string
          format: date-time

    EditorialFramework:
      type: object
      description: Structured 5-point editorial framework.
      properties:
        what_happened:
          type: string
          example: "The MPC raised the benchmark rate by 50 bps to 27.5%."
        why_it_matters:
          type: string
          example: "Commercial borrowing rates will rise to 32%-35% across Nigerian banks."
        where_is_the_money:
          type: string
          example: "Fixed-income yields gain while SME operating margins compress."
        who_gains_or_loses:
          type: string
          example: "Savers and foreign portfolio investors gain; leveraged manufacturers lose."
        what_next:
          type: string
          example: "Expect tighter credit conditions and higher consumer inflation in Q4."

    ArticleDetail:
      allOf:
        - $ref: '#/components/schemas/Article'
        - type: object
          properties:
            body_html:
              type: string
              description: Article body formatted in British English style.
            editorial_framework:
              $ref: '#/components/schemas/EditorialFramework'
            video_embed:
              $ref: '#/components/schemas/VideoEmbed'
            source_attribution:
              type: object
              properties:
                source_outlet_name:
                  type: string
                  example: "Central Bank of Nigeria Communiqué"
                original_url:
                  type: string
                  format: uri
            author:
              $ref: '#/components/schemas/AuthorProfile'

    ArticleCreateRequest:
      type: object
      required:
        - title
        - slug
        - section
        - source_type
        - body_html
      properties:
        title:
          type: string
        slug:
          type: string
        summary:
          type: string
        section:
          $ref: '#/components/schemas/SectionEnum'
        tags:
          type: array
          items:
            type: string
        source_type:
          $ref: '#/components/schemas/SourceTypeEnum'
        body_html:
          type: string
        featured_image_url:
          type: string
          format: uri
        what_happened:
          type: string
        why_it_matters:
          type: string
        where_is_the_money:
          type: string
        who_gains_or_loses:
          type: string
        what_next:
          type: string
        video_embed_id:
          type: string
          format: uuid
        source_outlet_name:
          type: string
        original_url:
          type: string
          format: uri

    GuestColumnSubmission:
      type: object
      required:
        - contributor_name
        - contributor_email
        - column_title
        - pitch_or_body
        - conflict_of_interest_disclosure
      properties:
        contributor_name:
          type: string
        contributor_email:
          type: string
          format: email
        bio:
          type: string
        social_or_portfolio_url:
          type: string
          format: uri
        column_title:
          type: string
        pitch_or_body:
          type: string
        conflict_of_interest_disclosure:
          type: string
          description: Declaration of investments, employer affiliations, or client ties.

    LiveTVVideo:
      type: object
      required:
        - id
        - title
        - program_type
        - video_url
        - duration_seconds
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
          example: "Nigeria Is Now Exporting Fuel to Europe"
        program_type:
          $ref: '#/components/schemas/VideoProgramEnum'
        video_url:
          type: string
          format: uri
        thumbnail_url:
          type: string
          format: uri
        duration_seconds:
          type: integer
          example: 60
        transcript:
          type: string
        cross_posted_article_slug:
          type: string
          example: "nigeria-fuel-exports-surge-dangote"

    VideoEmbed:
      type: object
      properties:
        video_id:
          type: string
          format: uuid
        embed_url:
          type: string
          format: uri
        aspect_ratio:
          type: string
          example: "16:9"

    AuthorProfile:
      type: object
      properties:
        name:
          type: string
        role:
          type: string
          example: "News Reporter"
        bio:
          type: string
        avatar_url:
          type: string
          format: uri

    HealthResponse:
      type: object
      required:
        - status
        - version
        - timestamp
        - service
        - environment
        - database
      properties:
        status:
          type: string
          example: "healthy"
        version:
          type: string
          example: "1.0.0"
        timestamp:
          type: string
          format: date-time
        service:
          type: string
          example: "businesswire-api"
        environment:
          type: string
          example: "production"
        database:
          type: string
          example: "connected"

    RateLimitError:
      type: object
      required:
        - error
        - message
        - retry_after
        - service
      properties:
        error:
          type: string
          example: "rate_limit_exceeded"
        message:
          type: string
          example: "Rate limit exceeded: 10 per 1 minute. Please slow down your requests."
        retry_after:
          type: integer
          example: 60
        service:
          type: string
          example: "businesswire-api"

    LiveTVVideoCreate:
      type: object
      required:
        - title
        - program_type
        - video_url
        - duration_seconds
      properties:
        title:
          type: string
          example: "Nigeria Is Now Exporting Fuel to Europe"
        program_type:
          $ref: '#/components/schemas/VideoProgramEnum'
        video_url:
          type: string
          format: uri
        thumbnail_url:
          type: string
          format: uri
        duration_seconds:
          type: integer
          example: 60
        transcript:
          type: string
        cross_posted_article_slug:
          type: string
          example: "nigeria-fuel-exports-surge-dangote"

    GuestColumnSubmissionResponse:
      type: object
      required:
        - id
        - contributor_name
        - contributor_email
        - column_title
        - pitch_or_body
        - conflict_of_interest_disclosure
        - status
      properties:
        id:
          type: string
          format: uuid
        contributor_name:
          type: string
        contributor_email:
          type: string
          format: email
        column_title:
          type: string
        pitch_or_body:
          type: string
        conflict_of_interest_disclosure:
          type: string
        bio:
          type: string
        social_or_portfolio_url:
          type: string
          format: uri
        status:
          type: string
          example: pending_review
        created_at:
          type: string
          format: date-time

    PopUpAdvertResponse:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        subtitle:
          type: string
        advertiser_name:
          type: string
        image_url:
          type: string
        cta_text:
          type: string
        cta_url:
          type: string
        trigger_type:
          type: string
          enum: [delay, scroll_depth, exit_intent]
        delay_seconds:
          type: integer
        scroll_percent:
          type: integer
        target_sections:
          type: array
          items:
            type: string
        is_active:
          type: boolean
        frequency_cap_hours:
          type: integer
        impressions:
          type: integer
        clicks:
          type: integer
        created_at:
          type: string
          format: date-time

    PopUpAdvertCreate:
      type: object
      required:
        - title
        - advertiser_name
        - cta_text
        - cta_url
      properties:
        title:
          type: string
        subtitle:
          type: string
        advertiser_name:
          type: string
        image_url:
          type: string
        cta_text:
          type: string
        cta_url:
          type: string
        trigger_type:
          type: string
          enum: [delay, scroll_depth, exit_intent]
          default: delay
        delay_seconds:
          type: integer
          default: 5
        scroll_percent:
          type: integer
          default: 50
        target_sections:
          type: array
          items:
            type: string
          default: ["all"]
        is_active:
          type: boolean
          default: true
        frequency_cap_hours:
          type: integer
          default: 24

    AdCampaignResponse:
      type: object
      properties:
        id:
          type: string
        campaign_name:
          type: string
        advertiser_name:
          type: string
        client_contact_email:
          type: string
        status:
          type: string
          enum: [active, scheduled, paused, completed]
        start_date:
          type: string
        end_date:
          type: string
        budget_ngn:
          type: integer
        spent_ngn:
          type: integer
        target_impressions:
          type: integer
        delivered_impressions:
          type: integer
        clicks:
          type: integer
        placement_type:
          type: string

    AdCampaignCreate:
      type: object
      required:
        - campaign_name
        - advertiser_name
        - client_contact_email
        - budget_ngn
      properties:
        campaign_name:
          type: string
        advertiser_name:
          type: string
        client_contact_email:
          type: string
        status:
          type: string
          enum: [active, scheduled, paused, completed]
          default: scheduled
        start_date:
          type: string
        end_date:
          type: string
        budget_ngn:
          type: integer
        target_impressions:
          type: integer
          default: 100000
        placement_type:
          type: string
          default: multi_channel

    DisplayBannerResponse:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        slot:
          type: string
        dimensions:
          type: string
        advertiser_name:
          type: string
        banner_image_url:
          type: string
        target_url:
          type: string
        is_active:
          type: boolean
        impressions:
          type: integer
        clicks:
          type: integer
        cpm_ngn:
          type: integer

    DisplayBannerCreate:
      type: object
      required:
        - name
        - slot
        - dimensions
        - advertiser_name
        - banner_image_url
        - target_url
      properties:
        name:
          type: string
        slot:
          type: string
        dimensions:
          type: string
        advertiser_name:
          type: string
        banner_image_url:
          type: string
        target_url:
          type: string
        is_active:
          type: boolean
          default: true
        cpm_ngn:
          type: integer
          default: 2500

  responses:
    400BadRequest:
      description: Invalid payload or missing mandatory taxonomy fields.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    404NotFound:
      description: Requested resource was not found.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    429TooManyRequests:
      description: Rate limit exceeded.
      headers:
        Retry-After:
          description: Number of seconds to wait before retrying the request.
          schema:
            type: integer
            example: 60
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'

  securitySchemes:
    KeycloakOAuth2:
      type: oauth2
      description: Keycloak OpenID Connect / OAuth2 Authentication. Use client ID `bw-client` and secret.
      flows:
        clientCredentials:
          tokenUrl: http://localhost:8080/realms/master/protocol/openid-connect/token
          scopes:
            openid: OpenID Connect identity
            profile: User profile and client claims
            email: Email verification claim
        authorizationCode:
          authorizationUrl: http://localhost:8080/realms/master/protocol/openid-connect/auth
          tokenUrl: http://localhost:8080/realms/master/protocol/openid-connect/token
          scopes:
            openid: OpenID Connect identity
            profile: User profile
            email: User email
    KeycloakBearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Keycloak RS256 JWT Access Token passed in Authorization header or ?token query parameter.