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:
- Studio’s Campaigns workbench (
frontend/features/studio/components/ CampaignUnifiedTable.tsx) filterscb_campaign_ideasWHEREconverted_to_campaign=trueand joins back tocb_campaignsviaconverted_campaign_id. With no paired idea row, MCP-created campaigns were invisible in the workbench (only the direct/studio?campaignId=...URL worked). - 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_progresswhen generating, elsedraft) - INSERT paired cb_campaign_ideas row with
source='mcp',converted_to_campaign=true,converted_campaign_id=<new> - INSERT cb_campaign_metadata with
total_documentscalculated from the target channels - Scaffold
sequence+step_catalogstub 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
Request Body required
object
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.
Campaign category
Campaign name
Responses
200
Successful Response
object
object
422
Validation Error