Ads
Package ads is your paid ad campaigns, launched and paused from one place.
Package ads is your paid ad campaigns, launched and paused from one place.
| Base URL | https://api.hanzo.ai |
| Operations | 7 |
| Auth | Authorization: Bearer $HANZO_API_KEY |
ads
POST /v1/ads/campaigns/{id}/launch
Run one of your stored campaigns on its ad network
Creates the campaign on its platform under the CALLER ORG'S own connected ad account, records the provider campaign id, flips the stored campaign to active and answers the updated record. No ad-network token is held here: it is resolved from KMS through the org's connector at launch time, BEFORE any provider call, so an org that has not connected that platform gets 424 and no spend can ever start on a connection the org did not make. Meta is executed for real; a campaign on a platform whose provider is not wired yet answers 501 even when the connector is connected, and an edge failure at the platform is 502. The optional {account} body overrides the target ad account for this launch and is TOLERANT — a malformed or non-JSON body is ignored and the campaign launches on its stored account rather than being refused. A campaign id another org owns reads as not found.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
GET /v1/ads/campaigns/{id}
Returns one of the caller org's campaigns. An id another org owns reads as not found, so the response cannot confirm that it exists.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
PUT /v1/ads/campaigns/{id}
Replaces the user-owned fields of one of the caller org's campaigns and answers the stored row. It is a full replace, not a patch: every field is written from the request, so an omitted one is cleared. externalId is launch-owned and is never touched here, so editing a campaign cannot break its link to a live provider execution.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Request body — application/json (required)
| Field | Type | Required | Description |
|---|---|---|---|
account | string | — | Account is the provider ad-account this campaign runs on (Meta act_<id>). |
budget | integer | — | Budget is the campaign budget in MINOR units (cents). |
name | string | — | Name is the campaign's display label. |
objective | string | — | Objective is the campaign goal as the provider names it. |
platform | string | — | Platform is the ad network: meta, google, tiktok or x. |
spend | integer | — | Spend is the amount spent so far in MINOR units (cents). |
status | string | — | Status is the lifecycle state: draft, active, paused or completed. |
DELETE /v1/ads/campaigns/{id}
Removes one of the caller org's campaigns and answers 204 with no body. It deletes the stored record only: a campaign already launched keeps running on the ad network, which must be stopped there. An id another org owns reads as not found.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
GET /v1/ads/campaigns
Returns the caller org's ad campaigns, most recently updated first, optionally narrowed to one lifecycle status. The listing is bounded by the org: another tenant's campaigns are not reachable from here at all.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
status | query | string | — | Status filters to one lifecycle state (draft, active, paused, completed). |
limit | query | integer | — | Limit caps how many campaigns come back: default 200, maximum 1000. |
POST /v1/ads/campaigns
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/ads/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 body — application/json (required)
| Field | Type | Required | Description |
|---|---|---|---|
account | string | — | Account is the provider ad-account this campaign runs on (Meta act_<id>). |
budget | integer | — | Budget is the campaign budget in MINOR units (cents). |
name | string | — | Name is the campaign's display label. |
objective | string | — | Objective is the campaign goal as the provider names it. |
platform | string | — | Platform is the ad network: meta, google, tiktok or x. |
spend | integer | — | Spend is the amount spent so far in MINOR units (cents). |
status | string | — | Status is the lifecycle state: draft, active, paused or completed. |
GET /v1/ads/summary
Rolls the caller org's ad campaigns up into four numbers: how many campaigns exist, how many are active, and the summed budget and spend across all of them. Budget and spend are MINOR units (cents), the same units the campaign rows carry. It counts only this org's campaigns.
How is this guide?