Create Campaign
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) 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).
- 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.
Request
- Base URL: https://be.graph8.com/api/v1
- URL: https://be.graph8.com/api/v1/campaigns
- Auth: HTTP bearer
Headers
Request body
Response
Successful Response
Changes
No recorded changes to this operation across all 2 revisions of this API.