> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aitasker.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Brand Intelligence Group Insights Route

> Aggregate ad signals across one Tracked Brands group (INSIGHTS tab).

POST because the group is a client-curated advertiser-id set (groups other
than Competitors/Default live in localStorage, not the DB).

Precisely because the cohort is client-curated there is no server-side
membership to inherit, so every id is narrowed through
``visible_advertiser_ids`` before anything reads it (finding C2 / ruling
R21). ``_get_brand_or_404`` proves ownership of ``brand_id`` only --
without this narrowing, any UUID in the body returned that advertiser's
name, domain and aggregates. The own-brand REFERENCE column is resolved
server-side below and is deliberately not part of the caller-supplied set.



## OpenAPI

````yaml /openapi.json post /api/v1/brands/{brand_id}/brand-intelligence/group-insights
openapi: 3.1.0
info:
  title: AITasker
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/brands/{brand_id}/brand-intelligence/group-insights:
    post:
      tags:
        - Brand Intelligence
        - Brand Intelligence
      summary: Get Brand Intelligence Group Insights Route
      description: >-
        Aggregate ad signals across one Tracked Brands group (INSIGHTS tab).


        POST because the group is a client-curated advertiser-id set (groups
        other

        than Competitors/Default live in localStorage, not the DB).


        Precisely because the cohort is client-curated there is no server-side

        membership to inherit, so every id is narrowed through

        ``visible_advertiser_ids`` before anything reads it (finding C2 / ruling

        R21). ``_get_brand_or_404`` proves ownership of ``brand_id`` only --

        without this narrowing, any UUID in the body returned that advertiser's

        name, domain and aggregates. The own-brand REFERENCE column is resolved

        server-side below and is deliberately not part of the caller-supplied
        set.
      operationId: >-
        get_brand_intelligence_group_insights_route_api_v1_brands__brand_id__brand_intelligence_group_insights_post
      parameters:
        - name: brand_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Brand Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BrandIntelligenceGroupInsightsRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BrandIntelligenceGroupInsightsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    BrandIntelligenceGroupInsightsRequest:
      properties:
        advertiser_ids:
          items:
            type: string
            format: uuid
          type: array
          maxItems: 60
          minItems: 1
          title: Advertiser Ids
        group_label:
          anyOf:
            - type: string
              maxLength: 120
            - type: 'null'
          title: Group Label
        date_from:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Date From
        date_to:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Date To
      type: object
      required:
        - advertiser_ids
      title: BrandIntelligenceGroupInsightsRequest
      description: One Tracked Brands group (client-curated advertiser set) to aggregate.
    BrandIntelligenceGroupInsightsResponse:
      properties:
        generated_at:
          type: string
          format: date-time
          title: Generated At
        group_key:
          type: string
          title: Group Key
        group_label:
          anyOf:
            - type: string
            - type: 'null'
          title: Group Label
        brand_count:
          type: integer
          title: Brand Count
          default: 0
        dated_ad_count:
          type: integer
          title: Dated Ad Count
          default: 0
        date_from:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Date From
        date_to:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Date To
        signals:
          $ref: '#/components/schemas/AdLibraryAdSignals'
        brands:
          items:
            $ref: '#/components/schemas/BrandIntelligenceGroupBrandRollup'
          type: array
          title: Brands
        launched_by_weekday:
          items:
            $ref: '#/components/schemas/BrandIntelligenceGroupWeekdayBucket'
          type: array
          title: Launched By Weekday
        own_brand:
          anyOf:
            - $ref: '#/components/schemas/BrandIntelligenceGroupBrandRollup'
            - type: 'null'
        own_brand_state:
          type: string
          enum:
            - measured
            - not_resolved
            - no_ads
            - below_minimum
          title: Own Brand State
          default: not_resolved
        own_brand_classified_ads:
          type: integer
          title: Own Brand Classified Ads
          default: 0
        dominant_industry:
          anyOf:
            - type: string
            - type: 'null'
          title: Dominant Industry
      type: object
      required:
        - generated_at
        - group_key
        - signals
      title: BrandIntelligenceGroupInsightsResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AdLibraryAdSignals:
      properties:
        total_ads:
          type: integer
          title: Total Ads
          default: 0
        active_ads:
          type: integer
          title: Active Ads
          default: 0
        inactive_ads:
          type: integer
          title: Inactive Ads
          default: 0
        dated_ads:
          type: integer
          title: Dated Ads
          default: 0
        themed_ads:
          type: integer
          title: Themed Ads
          default: 0
        new_ads_30d:
          type: integer
          title: New Ads 30D
          default: 0
        new_ads_14d:
          type: integer
          title: New Ads 14D
          default: 0
        new_ads_7d:
          type: integer
          title: New Ads 7D
          default: 0
        first_seen_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: First Seen At
        last_seen_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Seen At
        longest_active_days:
          anyOf:
            - type: integer
            - type: 'null'
          title: Longest Active Days
        avg_active_days:
          anyOf:
            - type: number
            - type: 'null'
          title: Avg Active Days
        run_length_measured_ads:
          type: integer
          title: Run Length Measured Ads
          default: 0
        distinct_concepts:
          type: integer
          title: Distinct Concepts
          default: 0
        avg_video_duration_seconds:
          anyOf:
            - type: number
            - type: 'null'
          title: Avg Video Duration Seconds
        platforms:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Platforms
        formats:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Formats
        landing_domains:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Landing Domains
        landing_pages:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Landing Pages
        hooks:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Hooks
        ctas:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Ctas
        countries:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Countries
        languages:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Languages
        industries:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Industries
        themes:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Themes
        launched_by_month:
          items:
            $ref: '#/components/schemas/AdLibraryMonthBucket'
          type: array
          title: Launched By Month
      type: object
      title: AdLibraryAdSignals
      description: >-
        Full-history rollups over ALL of an advertiser's stored ads.


        Server-computed so the Full Brand Page shows true totals — the previous

        client-side derivation only saw the capped ``recent_ads`` window, which

        made "first ad seen" and every distribution chip wrong for any
        advertiser

        with more than one page of ads. Bucket semantics mirror the Explore

        surfaces: ``platforms`` uses the same Meta publisher-platform expansion
        as

        the pill counts, ``landing_domains`` the same domain normalization as
        the

        ``landing_domain`` filter.
    BrandIntelligenceGroupBrandRollup:
      properties:
        advertiser_id:
          type: string
          format: uuid
          title: Advertiser Id
        name:
          type: string
          title: Name
        domain:
          anyOf:
            - type: string
            - type: 'null'
          title: Domain
        total_ads:
          type: integer
          title: Total Ads
          default: 0
        active_ads:
          type: integer
          title: Active Ads
          default: 0
        new_ads_30d:
          type: integer
          title: New Ads 30D
          default: 0
        image_ads:
          type: integer
          title: Image Ads
          default: 0
        video_ads:
          type: integer
          title: Video Ads
          default: 0
        other_ads:
          type: integer
          title: Other Ads
          default: 0
        dated_ads:
          type: integer
          title: Dated Ads
          default: 0
        platform_mapped_ads:
          type: integer
          title: Platform Mapped Ads
          default: 0
        platform_mapped_image_ads:
          type: integer
          title: Platform Mapped Image Ads
          default: 0
        platform_mapped_video_ads:
          type: integer
          title: Platform Mapped Video Ads
          default: 0
        platform_mapped_other_ads:
          type: integer
          title: Platform Mapped Other Ads
          default: 0
        platforms:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Platforms
        themed_ads:
          type: integer
          title: Themed Ads
          default: 0
        themes:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Themes
        last_seen_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Seen At
      type: object
      required:
        - advertiser_id
        - name
      title: BrandIntelligenceGroupBrandRollup
      description: Per-brand slice of a group aggregate (chart rows, not the tracker grid).
    BrandIntelligenceGroupWeekdayBucket:
      properties:
        weekday:
          type: integer
          maximum: 6
          minimum: 0
          title: Weekday
        total:
          type: integer
          minimum: 0
          title: Total
          default: 0
        brands:
          items:
            $ref: '#/components/schemas/AdLibraryCountBucket'
          type: array
          title: Brands
      type: object
      required:
        - weekday
      title: BrandIntelligenceGroupWeekdayBucket
      description: Ads launched on one weekday, stacked by top contributing brands.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    AdLibraryCountBucket:
      properties:
        key:
          type: string
          title: Key
        count:
          type: integer
          minimum: 0
          title: Count
          default: 0
        image_count:
          type: integer
          minimum: 0
          title: Image Count
          default: 0
        video_count:
          type: integer
          minimum: 0
          title: Video Count
          default: 0
        other_count:
          type: integer
          minimum: 0
          title: Other Count
          default: 0
      type: object
      required:
        - key
      title: AdLibraryCountBucket
      description: >-
        One distribution bucket of an advertiser's ads (e.g. platform → count).


        ``count`` is unchanged: every ad that falls in this bucket, regardless
        of

        creative format. The three ``*_count`` fields split that same total by
        the

        ad's SINGLE format class (see

        ``advertiser_signals.format_class_for_ad``) so the INSIGHTS tab can
        render

        an image/video/other stack, or filter to one class, without a second
        round

        trip.


        INVARIANT: ``image_count + video_count + other_count == count``.

        Producers that cannot classify must leave all three at 0 AND set count
        to 0.
    AdLibraryMonthBucket:
      properties:
        month:
          type: string
          title: Month
        count:
          type: integer
          minimum: 0
          title: Count
          default: 0
      type: object
      required:
        - month
      title: AdLibraryMonthBucket
      description: Ads launched in one ``YYYY-MM`` month (advertiser ad-velocity series).
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````