Create campaigns

Registers a new ad campaign for the caller's org and answers 201 with the stored row.

POST /v1/ad/campaigns

Addresshttps://api.hanzo.ai/v1/ad/campaigns
MethodPOST
Operationpost_ad_campaigns
AuthAuthorization: Bearer $HANZO_API_KEY

Registers a new ad campaign for the caller's org and answers 201 with the stored row. It only records the campaign — nothing is sent to the ad network until POST /v1/ad/campaigns/{id}/launch runs it. The org is stamped by the server from the validated principal, so a body can never place a campaign in another tenant.

Request

7 fields, body application/json (required).

FieldInTypeRequiredDescription
accountbodystring—Account is the provider ad-account this campaign runs on (Meta act_<id>).
budgetbodyinteger (int64)—Budget is the campaign budget in MINOR units (cents).
namebodystring—Name is the campaign's display label.
objectivebodystring—Objective is the campaign goal as the provider names it.
platformbodystring—Platform is the ad network: meta, google, tiktok or x.
spendbodyinteger (int64)—Spend is the amount spent so far in MINOR units (cents).
statusbodystring—Status is the lifecycle state: draft, active, paused or completed.

Response

StatusBodyMeaning
201ad.AdCampaigncreated
defaultproblem-detailsrefused

201 body — 11 fields.

FieldInTypeAlwaysDescription
accountbodystring—Account is the provider ad-account the campaign runs under, in Meta's act_<id> form.
budgetbodyinteger (int64)—Budget is the campaign's authorized spend in MINOR units (cents).
createdAtbodyinteger (int64)—CreatedAt is when the campaign was first stored, in unix seconds.
externalIdbodystring—ExternalID is the ad network's own campaign id, written by a successful launch and by nothing else — an update never touches it.
idbodystring—ID is the campaign's server-minted handle, "camp_" + 32 hex.
namebodystring—Name is the campaign's display label, and the name Meta creates the campaign object under at launch.
objectivebodystring—Objective is the campaign goal spelled as the provider names it ("conversions", "OUTCOME_TRAFFIC"), passed through to the network verbatim at launch — Meta defaults an empty one to OUTCOME_TRAFFIC.
platformbodystring—Platform is the ad network: meta, google, tiktok or x, and nothing else — a write naming another is 400.
spendbodyinteger (int64)—Spend is spend-to-date in MINOR units (cents), as last written through create or update.
statusbodystring—Status is the lifecycle: draft, active, paused or completed, and nothing else — a write naming another is 400.
updatedAtbodyinteger (int64)—UpdatedAt is when the row was last written, in unix seconds — set by create, update and launch.

Failure carries the platform error shape — see Errors.

Examples

hanzo ad campaigns create
import { Configuration, AdApi } from 'hanzoai';

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

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

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

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

let result = ad_api::post_ad_campaigns(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AdApi;

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

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

MCP reaches ad through the ad tool, which names its 6 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_ad_campaigns"
         }
       }
     }'

Ad API · All Hanzo APIs · Interactive reference

Was this page useful?