GTM Campaigns

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:

  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.

post/campaigns

Request

  • Base URL: https://be.graph8.com/api/v1
  • URL: https://be.graph8.com/api/v1/campaigns
  • Auth: HTTP bearer

Headers

Authorizationstring nullable
X-Target-Org-Idstring nullable

Request body

namestring required

Campaign name

categorystring

Campaign category

briefstring nullable

Campaign brief

core_conceptstring nullable

Core concept

primary_hookstring nullable

Primary hook text

target_personastring nullable

Target persona

goalstring nullable

Campaign goal

audience_list_idstring nullable

If provided, attaches this list ID to cb_campaigns.audience_list_id at create time.

target_channelsstring[] nullable

Channels the campaign will use, e.g. ['email'], ['email','linkedin']. Drives which copy documents the auto-generator creates. Defaults to ['email'].

execution_targetsstring[] nullable

Execution destinations: sequencer, dialer, or content_only.

secondary_hooksstring[] nullable

Additional hook variations to seed the campaign idea with.

auto_generate_documentsboolean

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.

Response

Successful Response

dataobject required

Changes

No recorded changes to this operation across all 2 revisions of this API.