Skip to content

Create Campaign

POST
/campaigns

Create a new campaign from scratch — full Studio “Convert to Campaign” parity.

The original handler only inserted cb_campaigns. That left two Studio-side gaps:

  1. Studio’s Campaigns workbench (frontend/features/studio/components/ CampaignUnifiedTable.tsx) filters cb_campaign_ideas WHERE converted_to_campaign=true and joins back to cb_campaigns via converted_campaign_id. With no paired idea row, MCP-created campaigns were invisible in the workbench (only the direct /studio?campaignId=... URL worked).
  2. No documents were generated, so the campaign sat in “Not Ready” state indefinitely. The launch flow silently produced empty sequences.

This handler now mirrors campaign_builder/routers/campaign_conversion.py :convert_idea_to_campaign end-to-end:

  • INSERT cb_campaigns (status=copy_in_progress when generating, else draft)
  • INSERT paired cb_campaign_ideas row with source='mcp', converted_to_campaign=true, converted_campaign_id=<new>
  • INSERT cb_campaign_metadata with total_documents calculated from the target channels
  • Scaffold sequence + step_catalog stub docs (idempotent)
  • Dispatch generate_campaign_files_from_idea.delay(...) to Celery

Backwards-compatible: original 7-field callers still work AND see byte-for-byte identical behavior because auto_generate_documents defaults to False. All Studio-parity behavior (paired idea row, metadata row, Celery dispatch, status=‘copy_in_progress’) is opt-in via auto_generate_documents=True. The MCP g8_gtm_create_campaign tool wrapper sets it to True so Daniel’s GTM agent gets the fix without affecting any other direct API caller.

Authorizations

Parameters

Header Parameters

X-Target-Org-Id
Any of:
string

Request Body required

object
audience_list_id
Any of:
string
auto_generate_documents

When True, dispatches the Celery campaign-content generator asynchronously after creation: the paired cb_campaign_ideas row is inserted (so the FE workbench sees the campaign), cb_campaign_metadata is created, the campaign starts in status=‘copy_in_progress’, and flips to ‘active’ once docs are ready (~60-90s). Default is False to preserve byte-for-byte backwards compatibility with the original bare-bones draft behavior — the MCP tool wrapper sets True explicitly to opt into Studio parity.

boolean
brief
Any of:
string
category

Campaign category

string
default: Outbound <= 100 characters
core_concept
Any of:
string
execution_targets
Any of:
Array<string>
goal
Any of:
string
<= 255 characters
name
required

Campaign name

string
<= 255 characters
primary_hook
Any of:
string
secondary_hooks
Any of:
Array<string>
target_channels
Any of:
Array<string>
target_persona
Any of:
string
<= 200 characters

Responses

200

Successful Response

object
data
required
object
key
additional properties
any
pagination
Any of:
object
has_next
required

Whether there are more pages

boolean
limit
required

Items per page

integer
next_cursor
Any of:
string
page
required

Current page number (1-indexed)

integer
total
required

Total number of items

integer

422

Validation Error

object
detail
Array<object>
object
loc
required
Array
msg
required
string
type
required
string