Create campaigns

Registers a campaign in the caller's org.

POST /v1/marketing/campaigns

Addresshttps://api.hanzo.ai/v1/marketing/campaigns
MethodPOST
Operationpost_marketing_campaigns
AuthAuthorization: Bearer $HANZO_API_KEY

Registers a campaign in the caller's org. Name is required; channel defaults to email and status to draft, and a future scheduledAt with no explicit status makes the campaign "scheduled". Budget and spend are cents and are clamped to >= 0. The id, createdAt and updatedAt of the input are ignored — the server assigns them.

Request

10 fields, body application/json (required).

FieldInTypeRequiredDescription
budgetbodyinteger (int64)—Budget is what the campaign is allowed to cost, in USD cents.
channelbodystring—Channel is the delivery surface: email, sms, social, meta, google or tiktok.
createdAtbodyinteger (int64)—CreatedAt is unix seconds when the campaign was registered.
idbodystring—ID is the server-assigned campaign id ("camp_" + 128 random bits).
namebodystring—Name is the campaign's label.
objectivebodystring—Objective is the free-text goal ("signups"), capped at 1024 bytes.
scheduledAtbodyinteger (int64)—ScheduledAt is the unix send time; 0 means unscheduled.
spendbodyinteger (int64)—Spend is what the campaign has cost so far, in USD cents, clamped to >= 0.
statusbodystring—Status is the lifecycle: draft, scheduled, active, paused or completed.
updatedAtbodyinteger (int64)—UpdatedAt is unix seconds of the last write.

Response

StatusBodyMeaning
200marketing.Campaignok
defaultproblem-detailsrefused

200 body — 10 fields.

FieldInTypeAlwaysDescription
budgetbodyinteger (int64)—Budget is what the campaign is allowed to cost, in USD cents.
channelbodystring—Channel is the delivery surface: email, sms, social, meta, google or tiktok.
createdAtbodyinteger (int64)—CreatedAt is unix seconds when the campaign was registered.
idbodystring—ID is the server-assigned campaign id ("camp_" + 128 random bits).
namebodystring—Name is the campaign's label.
objectivebodystring—Objective is the free-text goal ("signups"), capped at 1024 bytes.
scheduledAtbodyinteger (int64)—ScheduledAt is the unix send time; 0 means unscheduled.
spendbodyinteger (int64)—Spend is what the campaign has cost so far, in USD cents, clamped to >= 0.
statusbodystring—Status is the lifecycle: draft, scheduled, active, paused or completed.
updatedAtbodyinteger (int64)—UpdatedAt is unix seconds of the last write.

Failure carries the platform error shape — see Errors.

Examples

hanzo marketing campaigns create
import { Configuration, MarketingApi } from 'hanzoai';

const api = new MarketingApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postMarketingCampaigns({ budget: 0, channel: "<channel>" });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import MarketingApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = MarketingApi(client).post_marketing_campaigns(budget=0, channel="<channel>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.MarketingAPI.PostMarketingCampaigns(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, marketing_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = marketing_api::post_marketing_campaigns(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.MarketingApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new MarketingApi(client).postMarketingCampaigns();
curl -X POST https://api.hanzo.ai/v1/marketing/campaigns \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "budget": 0,
       "channel": "<channel>"
     }'

MCP reaches marketing through the marketing tool, which names its 35 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_marketing_audiences"
         }
       }
     }'

Marketing API · All Hanzo APIs · Interactive reference

Was this page useful?