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

# Regenerate ad groups from keywords

> Re-split keywords into ad groups using Gemini AI.

This will delete existing ad groups and create new ones based on
the keywords currently in the draft. Runs as a background task.

When `from_market_analysis=true`, keywords are pulled fresh from the
linked market analysis instead of the draft's current ad groups.
This recovers keywords lost by deleting ad groups.



## OpenAPI

````yaml https://dev-api.cattix.com/openapi.json post /api/v1/campaigns/drafts/{draft_id}/ad-groups/regenerate
openapi: 3.1.0
info:
  title: CATTIX API
  description: CATTIX Backend API
  version: 0.107.0
servers:
  - url: http://localhost:8000
    description: Local
  - url: https://dev-api.cattix.com
    description: Development
  - url: https://staging-api.cattix.com
    description: Staging
  - url: https://api.cattix.com
    description: Production
security: []
paths:
  /api/v1/campaigns/drafts/{draft_id}/ad-groups/regenerate:
    post:
      tags:
        - Campaigns
      summary: Regenerate ad groups from keywords
      description: |-
        Re-split keywords into ad groups using Gemini AI.

        This will delete existing ad groups and create new ones based on
        the keywords currently in the draft. Runs as a background task.

        When `from_market_analysis=true`, keywords are pulled fresh from the
        linked market analysis instead of the draft's current ad groups.
        This recovers keywords lost by deleting ad groups.
      operationId: >-
        regenerate_ad_groups_api_v1_campaigns_drafts__draft_id__ad_groups_regenerate_post
      parameters:
        - name: draft_id
          in: path
          required: true
          schema:
            type: integer
            title: Draft Id
        - name: from_market_analysis
          in: query
          required: false
          schema:
            type: boolean
            description: >-
              Re-pull selected keywords from the linked market analysis instead
              of using existing draft keywords
            default: false
            title: From Market Analysis
          description: >-
            Re-pull selected keywords from the linked market analysis instead of
            using existing draft keywords
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegenerateAdGroupsRequestSchema'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegenerateAdGroupsResponseSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2PasswordBearer: []
components:
  schemas:
    RegenerateAdGroupsRequestSchema:
      properties:
        max_keywords_per_ad_group:
          type: integer
          maximum: 100
          minimum: 1
          title: Max Keywords Per Ad Group
          default: 20
        min_keywords_per_ad_group:
          type: integer
          maximum: 50
          minimum: 1
          title: Min Keywords Per Ad Group
          default: 3
      type: object
      title: RegenerateAdGroupsRequestSchema
      description: Request to regenerate ad groups from keywords.
    RegenerateAdGroupsResponseSchema:
      properties:
        task_id:
          type: string
          title: Task Id
        status:
          $ref: '#/components/schemas/TaskGenerationStatus'
          default: in_progress
      type: object
      required:
        - task_id
      title: RegenerateAdGroupsResponseSchema
      description: Response for ad group regeneration.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    TaskGenerationStatus:
      type: string
      enum:
        - not_started
        - pending
        - in_progress
        - completed
        - failed
      title: TaskGenerationStatus
      description: Status of background task generation (ad groups, RSAs).
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    OAuth2PasswordBearer:
      type: oauth2
      flows:
        password:
          scopes: {}
          tokenUrl: api/v1/users/authorization/token

````