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

# Create pre-populated campaign draft from market analysis

> Get pre-populated campaign configuration based on a market analysis.

This endpoint:
1. Creates a campaign draft internally
2. Kicks off async tasks for AI-powered ad group splitting and RSA generation
3. Returns immediately with draft_id and task_ids for polling

The response includes:
- Campaign name suggestion based on analysis title
- Location targets from analysis config
- Language targeting from analysis config
- Initial ad group with all selected keywords
- Suggested daily budget based on keyword bid estimates
- draft_id and task_ids for polling generation status

Poll `/drafts/{draft_id}/generation-status` to check task completion.
Once complete, fetch `/drafts/{draft_id}` for AI-generated ad groups and RSAs.

The following fields require user input and are returned empty:
- conversion_goals (defaults to ACCOUNT_DEFAULT, can be customized)
- extensions (optional, user-defined)



## OpenAPI

````yaml https://dev-api.cattix.com/openapi.json post /api/v1/campaigns/prefill
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/prefill:
    post:
      tags:
        - Campaigns
      summary: Create pre-populated campaign draft from market analysis
      description: >-
        Get pre-populated campaign configuration based on a market analysis.


        This endpoint:

        1. Creates a campaign draft internally

        2. Kicks off async tasks for AI-powered ad group splitting and RSA
        generation

        3. Returns immediately with draft_id and task_ids for polling


        The response includes:

        - Campaign name suggestion based on analysis title

        - Location targets from analysis config

        - Language targeting from analysis config

        - Initial ad group with all selected keywords

        - Suggested daily budget based on keyword bid estimates

        - draft_id and task_ids for polling generation status


        Poll `/drafts/{draft_id}/generation-status` to check task completion.

        Once complete, fetch `/drafts/{draft_id}` for AI-generated ad groups and
        RSAs.


        The following fields require user input and are returned empty:

        - conversion_goals (defaults to ACCOUNT_DEFAULT, can be customized)

        - extensions (optional, user-defined)
      operationId: create_campaign_prefill_api_v1_campaigns_prefill_post
      parameters:
        - name: market_analysis_id
          in: query
          required: true
          schema:
            type: integer
            description: Market analysis ID to prefill from
            title: Market Analysis Id
          description: Market analysis ID to prefill from
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignPrefillResponseSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2PasswordBearer: []
components:
  schemas:
    CampaignPrefillResponseSchema:
      properties:
        market_analysis_id:
          type: integer
          title: Market Analysis Id
        market_analysis_title:
          type: string
          title: Market Analysis Title
        google_ads_customer_id:
          type: integer
          title: Google Ads Customer Id
        suggested_campaign_name:
          type: string
          title: Suggested Campaign Name
        website_url:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          title: Website Url
        language_ids:
          items:
            type: integer
          type: array
          title: Language Ids
        location_targets:
          items:
            $ref: '#/components/schemas/LocationTargetSchema'
          type: array
          title: Location Targets
        network_settings:
          $ref: '#/components/schemas/NetworkSettingsSchema'
        ad_schedule:
          $ref: >-
            #/components/schemas/api__campaigns__schemas__AdScheduleSchema-Output
        default_match_type:
          $ref: '#/components/schemas/KeywordMatchTypes'
        ad_groups:
          items:
            $ref: '#/components/schemas/AdGroupInputSchema'
          type: array
          title: Ad Groups
        bidding_strategy:
          anyOf:
            - $ref: '#/components/schemas/BiddingStrategySchema'
            - type: 'null'
        conversion_goals:
          items:
            $ref: '#/components/schemas/ConversionGoalSchema'
          type: array
          title: Conversion Goals
        extensions:
          anyOf:
            - $ref: '#/components/schemas/ExtensionsInputSchema-Output'
            - type: 'null'
        draft_id:
          type: integer
          title: Draft Id
        ad_groups_task_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Ad Groups Task Id
        rsa_task_ids:
          items:
            type: string
          type: array
          title: Rsa Task Ids
        ad_groups_generation_status:
          $ref: '#/components/schemas/TaskGenerationStatus'
          default: pending
        ad_groups_generation_error:
          anyOf:
            - type: string
            - type: 'null'
          title: Ad Groups Generation Error
        rsas_generation_status:
          $ref: '#/components/schemas/TaskGenerationStatus'
          default: not_started
        extensions_generation_status:
          $ref: '#/components/schemas/TaskGenerationStatus'
          default: not_started
        is_published:
          type: boolean
          title: Is Published
          default: false
        all_rsas_generated:
          type: boolean
          title: All Rsas Generated
          default: false
      type: object
      required:
        - market_analysis_id
        - market_analysis_title
        - google_ads_customer_id
        - suggested_campaign_name
        - language_ids
        - location_targets
        - network_settings
        - ad_schedule
        - default_match_type
        - ad_groups
        - draft_id
      title: CampaignPrefillResponseSchema
      description: |-
        Response schema for campaign prefill from market analysis.

        Contains pre-populated campaign data derived from market analysis.
        A draft is created internally and async tasks are kicked off for
        ad group splitting and RSA generation.

        Fields requiring user input are returned as empty/null.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LocationTargetSchema:
      properties:
        geo_target_constant_id:
          type: integer
          exclusiveMinimum: 0
          title: Geo Target Constant Id
          description: Google Ads geo target constant ID
        target_type:
          $ref: >-
            #/components/schemas/api__google_ads_management__schemas__LocationTargetType
          default: INCLUDE
      type: object
      required:
        - geo_target_constant_id
      title: LocationTargetSchema
      description: Location targeting configuration.
    NetworkSettingsSchema:
      properties:
        target_google_search:
          type: boolean
          title: Target Google Search
          description: Target Google Search
          default: true
        target_search_network:
          type: boolean
          title: Target Search Network
          description: Target Search partners
          default: false
        target_content_network:
          type: boolean
          title: Target Content Network
          description: Target Display Network
          default: false
      type: object
      title: NetworkSettingsSchema
      description: Network settings for campaign.
    api__campaigns__schemas__AdScheduleSchema-Output:
      properties:
        mode:
          type: string
          enum:
            - ALL_TIME
            - CUSTOM
          title: Mode
        schedule_entries:
          anyOf:
            - items:
                $ref: '#/components/schemas/ScheduleEntrySchema'
              type: array
            - type: 'null'
          title: Schedule Entries
          description: Required if mode is CUSTOM
      type: object
      required:
        - mode
      title: AdScheduleSchema
      description: Ad schedule configuration.
    KeywordMatchTypes:
      type: string
      enum:
        - EXACT
        - PHRASE
        - BROAD
        - BROAD_MODIFIER
        - NEGATIVE
      title: KeywordMatchTypes
      description: The keyword match types.
    AdGroupInputSchema:
      properties:
        id:
          type: integer
          title: Id
          description: Draft ad group's real PK
        name:
          type: string
          maxLength: 256
          minLength: 1
          title: Name
        keywords:
          items:
            $ref: '#/components/schemas/KeywordInputSchema'
          type: array
          minItems: 1
          title: Keywords
        cpc_bid_micros:
          anyOf:
            - type: integer
              ge: 0
              le: 50000000000
            - type: 'null'
          title: Cpc Bid Micros
          description: Optional ad group level bid
      type: object
      required:
        - id
        - name
        - keywords
      title: AdGroupInputSchema
      description: Ad group input for campaign creation.
    BiddingStrategySchema:
      properties:
        type:
          $ref: '#/components/schemas/BiddingStrategyType'
        target_cpa_micros:
          anyOf:
            - type: integer
              ge: 0
              le: 50000000000
            - type: 'null'
          title: Target Cpa Micros
          description: Required if type is TARGET_CPA
        target_roas:
          anyOf:
            - type: number
              exclusiveMinimum: 0
            - type: 'null'
          title: Target Roas
          description: Required if type is TARGET_ROAS (e.g., 2.0 = 200%)
        max_cpc_bid_ceiling_micros:
          anyOf:
            - type: integer
              ge: 0
              le: 50000000000
            - type: 'null'
          title: Max Cpc Bid Ceiling Micros
          description: Optional ceiling for automated strategies
      type: object
      required:
        - type
      title: BiddingStrategySchema
      description: Bidding strategy configuration.
    ConversionGoalSchema:
      properties:
        conversion_action_id:
          anyOf:
            - type: integer
              exclusiveMinimum: 0
            - type: 'null'
          title: Conversion Action Id
          description: Google Ads conversion action ID
        goal_type:
          type: string
          enum:
            - CAMPAIGN_SPECIFIC
            - ACCOUNT_DEFAULT
          title: Goal Type
        category:
          anyOf:
            - $ref: '#/components/schemas/ConversionCategory'
            - type: 'null'
      type: object
      required:
        - goal_type
      title: ConversionGoalSchema
      description: Conversion goal configuration.
    ExtensionsInputSchema-Output:
      properties:
        sitelinks:
          anyOf:
            - items:
                $ref: '#/components/schemas/SitelinkInputSchema'
              type: array
              maxItems: 20
            - type: 'null'
          title: Sitelinks
        callouts:
          anyOf:
            - items:
                $ref: '#/components/schemas/CalloutInputSchema'
              type: array
              maxItems: 20
            - type: 'null'
          title: Callouts
        phone:
          anyOf:
            - $ref: '#/components/schemas/PhoneInputSchema'
            - type: 'null'
        structured_snippets:
          anyOf:
            - items:
                $ref: '#/components/schemas/StructuredSnippetInputSchema'
              type: array
            - type: 'null'
          title: Structured Snippets
      additionalProperties: false
      type: object
      title: ExtensionsInputSchema
      description: All extensions configuration.
    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
    api__google_ads_management__schemas__LocationTargetType:
      type: string
      enum:
        - INCLUDE
        - EXCLUDE
      title: LocationTargetType
      description: Location targeting type.
    ScheduleEntrySchema:
      properties:
        day_of_week:
          $ref: '#/components/schemas/DayOfWeek'
        start_hour:
          type: integer
          maximum: 23
          minimum: 0
          title: Start Hour
        start_minute:
          type: integer
          enum:
            - 0
            - 15
            - 30
            - 45
          title: Start Minute
          default: 0
        end_hour:
          type: integer
          maximum: 24
          minimum: 0
          title: End Hour
          description: 24 = midnight end
        end_minute:
          type: integer
          enum:
            - 0
            - 15
            - 30
            - 45
          title: End Minute
          default: 0
      type: object
      required:
        - day_of_week
        - start_hour
        - end_hour
      title: ScheduleEntrySchema
      description: Single schedule entry for ad scheduling.
    KeywordInputSchema:
      properties:
        text:
          type: string
          maxLength: 80
          minLength: 1
          title: Text
          description: The keyword phrase
        match_type:
          $ref: '#/components/schemas/KeywordMatchTypes'
        cpc_bid_micros:
          anyOf:
            - type: integer
              ge: 0
              le: 50000000000
            - type: 'null'
          title: Cpc Bid Micros
          description: Optional keyword level bid
        final_url:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          title: Final Url
          description: Optional keyword-level URL
        market_analysis_keyword_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Market Analysis Keyword Id
          description: Reference to source Market Analysis keyword
      type: object
      required:
        - text
        - match_type
      title: KeywordInputSchema
      description: Keyword input for an Ad Group.
    BiddingStrategyType:
      type: string
      enum:
        - MAXIMIZE_CONVERSIONS
        - MAXIMIZE_CONVERSION_VALUE
        - MAXIMIZE_CLICKS
        - TARGET_CPA
        - TARGET_ROAS
        - TARGET_IMPRESSION_SHARE
        - MANUAL_CPC
      title: BiddingStrategyType
      description: Supported bidding strategy types.
    ConversionCategory:
      type: string
      enum:
        - PURCHASE
        - SIGNUP
        - LEAD
        - PAGE_VIEW
        - DOWNLOAD
        - ADD_TO_CART
        - BEGIN_CHECKOUT
        - CONTACT
        - SUBMIT_LEAD_FORM
        - BOOK_APPOINTMENT
        - REQUEST_QUOTE
        - GET_DIRECTIONS
        - OUTBOUND_CLICK
        - OTHER
      title: ConversionCategory
      description: Conversion action categories.
    SitelinkInputSchema:
      properties:
        link_text:
          type: string
          maxLength: 25
          title: Link Text
        final_url:
          type: string
          maxLength: 2083
          minLength: 1
          format: uri
          title: Final Url
        description_1:
          anyOf:
            - type: string
              maxLength: 35
            - type: 'null'
          title: Description 1
        description_2:
          anyOf:
            - type: string
              maxLength: 35
            - type: 'null'
          title: Description 2
        final_mobile_url:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          title: Final Mobile Url
      additionalProperties: false
      type: object
      required:
        - link_text
        - final_url
      title: SitelinkInputSchema
      description: Sitelink extension input.
    CalloutInputSchema:
      properties:
        callout_text:
          type: string
          maxLength: 25
          title: Callout Text
      additionalProperties: false
      type: object
      required:
        - callout_text
      title: CalloutInputSchema
      description: Callout extension input.
    PhoneInputSchema:
      properties:
        phone_number:
          type: string
          title: Phone Number
          description: E.164 format preferred
        country_code:
          type: string
          pattern: ^[A-Z]{2}$
          title: Country Code
          description: ISO 3166-1 alpha-2, e.g., 'US'
      additionalProperties: false
      type: object
      required:
        - phone_number
        - country_code
      title: PhoneInputSchema
      description: Phone extension input.
    StructuredSnippetInputSchema:
      properties:
        header:
          $ref: '#/components/schemas/StructuredSnippetHeader'
        values:
          items:
            type: string
            maxLength: 25
            minLength: 1
          type: array
          maxItems: 10
          minItems: 3
          title: Values
      additionalProperties: false
      type: object
      required:
        - header
        - values
      title: StructuredSnippetInputSchema
      description: Structured snippet extension input.
    DayOfWeek:
      type: string
      enum:
        - MONDAY
        - TUESDAY
        - WEDNESDAY
        - THURSDAY
        - FRIDAY
        - SATURDAY
        - SUNDAY
      title: DayOfWeek
      description: Days of the week for ad scheduling.
    StructuredSnippetHeader:
      type: string
      enum:
        - AMENITIES
        - BRANDS
        - COURSES
        - DEGREE_PROGRAMS
        - DESTINATIONS
        - FEATURED_HOTELS
        - INSURANCE_COVERAGE
        - MODELS
        - NEIGHBORHOODS
        - SERVICE_CATALOG
        - SHOWS
        - STYLES
        - TYPES
      title: StructuredSnippetHeader
      description: Structured snippet header types.
  securitySchemes:
    OAuth2PasswordBearer:
      type: oauth2
      flows:
        password:
          scopes: {}
          tokenUrl: api/v1/users/authorization/token

````