> ## 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.

# Generate Post Ideas Route

> Generate post ideas from one own post or one tracked cohort.

Ownership is checked twice on purpose, because the two arms reach the
owning brand through different tables. The path check below proves the
caller owns THIS BRAND; the own-post arm then proves the post is one this
brand PUBLISHED (not merely one it tracks), and the cohort arm proves every
requested domain is one of this brand's tracked competitors. Neither arm's
check implies the other's.



## OpenAPI

````yaml /openapi.json post /api/v1/brands/{brand_id}/brand-intelligence/post-ideas/generate
openapi: 3.1.0
info:
  title: AITasker
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/brands/{brand_id}/brand-intelligence/post-ideas/generate:
    post:
      tags:
        - Brand Intelligence
        - Brand Intelligence
      summary: Generate Post Ideas Route
      description: >-
        Generate post ideas from one own post or one tracked cohort.


        Ownership is checked twice on purpose, because the two arms reach the

        owning brand through different tables. The path check below proves the

        caller owns THIS BRAND; the own-post arm then proves the post is one
        this

        brand PUBLISHED (not merely one it tracks), and the cohort arm proves
        every

        requested domain is one of this brand's tracked competitors. Neither
        arm's

        check implies the other's.
      operationId: >-
        generate_post_ideas_route_api_v1_brands__brand_id__brand_intelligence_post_ideas_generate_post
      parameters:
        - name: brand_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Brand Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/OwnPostIdeaRequest'
                - $ref: '#/components/schemas/GroupInsightsPostIdeaRequest'
              title: Payload
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostIdeaResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    OwnPostIdeaRequest:
      properties:
        count:
          type: integer
          maximum: 10
          minimum: 3
          title: Count
          description: How many post ideas to generate.
          default: 5
        source:
          type: string
          const: own_post
          title: Source
        post_id:
          type: string
          format: uuid
          title: Post Id
      additionalProperties: false
      type: object
      required:
        - source
        - post_id
      title: OwnPostIdeaRequest
      description: Generate ideas from one of the caller's OWN published posts.
    GroupInsightsPostIdeaRequest:
      properties:
        count:
          type: integer
          maximum: 10
          minimum: 3
          title: Count
          description: How many post ideas to generate.
          default: 5
        source:
          type: string
          const: group_insights
          title: Source
        domains:
          items:
            type: string
          type: array
          maxItems: 60
          minItems: 1
          title: Domains
        window_days:
          type: integer
          enum:
            - 7
            - 30
            - 90
          title: Window Days
          default: 30
        platforms:
          items:
            type: string
            enum:
              - youtube
              - x
              - linkedin
              - instagram
              - facebook
              - tiktok
          type: array
          maxItems: 6
          title: Platforms
        group_label:
          anyOf:
            - type: string
              maxLength: 200
            - type: 'null'
          title: Group Label
      additionalProperties: false
      type: object
      required:
        - source
        - domains
      title: GroupInsightsPostIdeaRequest
      description: >-
        Generate ideas from a tracked group's measured social patterns.


        Addressed by DOMAIN SET rather than by tracked-group id, unlike the hook

        generator's group arm. That is this boundary's own addressing scheme:

        ``SocialGroupInsightsRequest`` takes ``domains``, and

        ``get_social_group_insights`` validates every one of them against the

        brand's ``BrandCompetitor`` rows. Reusing the shipped gate the Insights
        tab

        already passes through beats resolving a second path to the same cohort.


        The comparison slice is carried too, because a pattern is only true of
        the

        window it was measured in - generating from a 90-day cohort while the
        user

        reads a 7-day tab would describe a cohort they cannot see.
    PostIdeaResponse:
      properties:
        source:
          type: string
          enum:
            - own_post
            - group_insights
          title: Source
        subject_label:
          anyOf:
            - type: string
            - type: 'null'
          title: Subject Label
        brand_id:
          type: string
          format: uuid
          title: Brand Id
        brand_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Brand Name
        source_signals:
          items:
            type: string
          type: array
          title: Source Signals
        ideas:
          items:
            $ref: '#/components/schemas/GeneratedPostIdea'
          type: array
          title: Ideas
        generated_at:
          type: string
          format: date-time
          title: Generated At
      type: object
      required:
        - source
        - brand_id
        - ideas
        - generated_at
      title: PostIdeaResponse
      description: The generated set plus enough provenance to render its header.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    GeneratedPostIdea:
      properties:
        idea:
          type: string
          maxLength: 300
          minLength: 1
          title: Idea
          description: What the post is, in one line.
        hook:
          type: string
          maxLength: 200
          minLength: 1
          title: Hook
          description: The opening line, as it would be read.
        format:
          type: string
          enum:
            - video
            - image
            - carousel
            - text
            - link
            - other
          title: Format
        angle:
          type: string
          maxLength: 280
          minLength: 1
          title: Angle
      type: object
      required:
        - idea
        - hook
        - format
        - angle
      title: GeneratedPostIdea
      description: >-
        One idea. ``angle`` is the visible "why", never optional.


        Design principle 4 — every generated result carries a visible reason —
        is a

        schema property here rather than a prompt hope: a payload without an

        ``angle`` fails validation before it can reach a caption slot.
    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
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````