Rewrites a campaign's core fields — name, audience, creatives, schedule and…
Rewrites a campaign's core fields — name, audience, creatives, schedule and budget — and returns the updated campaign.
PUT /v1/campaign/{id}
| Address | https://api.hanzo.ai/v1/campaign/{id} |
| Method | PUT |
| Operation | put_campaign_by_id |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Rewrites a campaign's core fields — name, audience, creatives, schedule and budget — and returns the updated campaign.
Channels are replaced ONLY while the campaign is still a draft. Once it is launched its channels carry provider state (an external id, a live status), so they are added and removed explicitly through the channels sub-resource instead; a whole-object write would silently orphan a running execution.
Request
14 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | ID is the campaign to update, from the path. |
audience | body | string | — | |
budget | body | integer | — | |
channels | body | ChannelSpec[] | — | |
channels[].account | body | string | — | Account is the provider account this channel runs under: an ad-account, a page or a mailing-list id. |
channels[].detail | body | string | — | Detail is the last outcome in one secret-free line — the failure reason, or what the executor reported. |
channels[].externalId | body | string | — | ExternalID is the provider-side id of the running execution, recorded by the orchestrator at launch and handed back verbatim to read spend or to pause. |
channels[].kind | body | string | — | Kind is the channel and the identity a campaign holds at most one of: paid, organic or email. |
channels[].platform | body | string | — | Platform is the provider within the kind — meta, google, x, instagram, or the email provider. |
channels[].status | body | string | — | Status is this channel's own launch outcome, not the campaign's: pending (added, never launched), live, paused, failed (Detail says why) or unavailable (no… |
content | body | string[] | — | |
id | body | string | — | ID is the campaign to update, from the path. |
name | body | string | — | |
scheduleAt | body | integer | — |
Response
| Status | Body | Meaning |
|---|---|---|
200 | campaignRecord | ok |
200 body — 16 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
audience | body | string | — | Audience is an opaque reference to the segment this campaign targets. |
budget | body | integer | — | Budget is the campaign's total budget in CENTS, handed to each executor as the budget for its channel. |
channels | body | ChannelSpec[] | — | Channels are the fan-out targets, at most one per kind and at most 12, each carrying its own post-launch state. |
channels[].account | body | string | — | Account is the provider account this channel runs under: an ad-account, a page or a mailing-list id. |
channels[].detail | body | string | — | Detail is the last outcome in one secret-free line — the failure reason, or what the executor reported. |
channels[].externalId | body | string | — | ExternalID is the provider-side id of the running execution, recorded by the orchestrator at launch and handed back verbatim to read spend or to pause. |
channels[].kind | body | string | — | Kind is the channel and the identity a campaign holds at most one of: paid, organic or email. |
channels[].platform | body | string | — | Platform is the provider within the kind — meta, google, x, instagram, or the email provider. |
channels[].status | body | string | — | Status is this channel's own launch outcome, not the campaign's: pending (added, never launched), live, paused, failed (Detail says why) or unavailable (no… |
content | body | string[] | — | Content is the ordered creative set, at most 32, empty entries dropped. |
createdAt | body | integer | — | CreatedAt is when the campaign was created, in unix seconds. |
id | body | string | — | ID is the campaign's server-minted handle — "cmp_" and 128 random bits — and the id every other campaign call is addressed by. |
name | body | string | — | Name is the campaign's display name. |
scheduleAt | body | integer | — | ScheduleAt is when the campaign should run, in unix seconds. 0 (absent) means launch immediately. |
status | body | string | — | Status is the lifecycle state, server-owned and never accepted from a caller. |
updatedAt | body | integer | — | UpdatedAt is the last write in unix seconds — an edit, a launch or a pause. |
Failure carries the platform error shape — see Errors.
Examples
hanzo campaign set <id>import { Configuration, CampaignApi } from 'hanzoai';
const api = new CampaignApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.putCampaignById({ id: 'id', audience: "<audience>", budget: 0 });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import CampaignApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = CampaignApi(client).put_campaign_by_id(id='id', audience="<audience>", budget=0)cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.CampaignAPI.PutCampaignById(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, campaign_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = campaign_api::put_campaign_by_id(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CampaignApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new CampaignApi(client).putCampaignById();curl -X PUT https://api.hanzo.ai/v1/campaign/<id> \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"audience": "<audience>",
"budget": 0
}'The door reaches campaign through the campaign tool, which names its 11 operations with its own verbs — this one among them, under a name only the door 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": "get_campaign"
}
}
}'How is this guide?