Xuda AI Advertising API Reference
Xuda AI Advertising API Reference
This reference covers the full method surface of Xuda AI Advertising: the seven methods an external developer API key can call, and the eight dashboard methods behind the campaign wizard and the Creative, Billing and Settings tabs. It is written for developers who want to read the ad-network catalog, generate ad copy, push a campaign into Google Ads or Meta, flip serving on and off, or pull daily performance into their own systems. Every method key, parameter name, type and required flag below is taken from the shipped method contract.
How To Call These Methods
Every method here is a CPI method. CPI methods are dispatched by name over the Xuda API and MCP layer, and the normal credential for that layer is the account API key. For the transport-level detail, including how requests are framed and how the MCP layer exposes methods, see /api-mcp-integration.
Parameters ride under a data object, so a request body looks like this:
{ "data": { "app_id": "..." } }
Fifteen methods are registered. Seven are reachable with a developer API key. The other eight are flagged private, and a private method is refused for an API-key caller no matter how much access that key carries, so those eight are dashboard-session methods. All fifteen run at user clearance and none carries a min_plan, so there is no membership tier to buy before you can call them.
Only get_account_advertising is exposed as an MCP tool. The other fourteen are registered with mcp: false.
Two ad networks are wired for launch today, google-ads and meta. The platform catalog ships 42 entries covering 40 unique networks, but every other slug is marked coming soon and launch_ad_campaign answers launch not yet wired for <slug> for it.
Ad-network credentials are never a parameter. Google Ads and Meta credentials are read server side from environment variables or from gitignored on-box secrets files, and the catalog's own credential objects are stripped from every response before it leaves the box.
What The Availability Labels Mean
Every method below carries one explicit availability line. Read it first, because it tells you whether you can call the method from your own code today.
- Availability: API key means an external developer API key or the MCP layer can call it. Seven AI Advertising methods carry this label.
- Availability: Dashboard session means a signed-in user in the Xuda dashboard can call it, and an API key cannot. The account identity comes from the session, never from a parameter. Eight AI Advertising methods carry this label.
- Availability: Public endpoint means no authentication at all. No AI Advertising method currently carries this label.
- Availability: Operator only means Xuda staff, listed only for completeness. No AI Advertising method currently carries this label.
The split matters in practice. An API key can read the catalog, write copy, create and update the real network campaigns, pause and resume serving on the networks, pull metrics and provision a Google Ads account. It cannot create a campaign, move money, change a budget, save creative, change settings or cancel, because everything that touches the campaign document or Stripe is session only.
Method Index
| Method | What It Does |
|---|---|
| get_advertise_platforms | Returns the ad-network catalog with credentials stripped from every entry. |
| generate_ad_creative | Writes headline, primary text, description and CTA for one platform in one tone. |
| launch_ad_campaign | Creates or updates the real campaign inside Google Ads or Meta, always paused. |
| set_ad_network_status | Pauses or resumes the live network campaigns for a Xuda campaign. |
| get_ad_campaign_report | Pulls daily clicks, impressions, spend and conversions from each launched network. |
| provision_google_ads_account | Creates the customer's own Google Ads client account under the Xuda manager account. |
| get_account_advertising | Lists the caller's advertising campaigns. |
| create_ad_campaign | Creates the campaign and charges the prepaid budget plus the automation fee. |
| cancel_ad_campaign | Cancels the campaign and ends recurring billing. |
| get_ad_campaign_billing | Reads the billing summary, subscription state and invoice history. |
| set_ad_campaign_card | Points the recurring subscription at a different saved card. |
| set_ad_campaign_status | Sets the campaign's own status and pauses or resumes Stripe collection. |
| update_ad_campaign_budget | Changes a recurring campaign's daily budget and reprices the subscription. |
| update_ad_campaign_creative | Saves edited ad copy, shared or per platform. |
| update_ad_campaign_settings | Saves autopilot mode, budget rules, dayparting and UTM tagging. |
get_advertise_platforms
Get Advertise Platforms
Returns the advertising-platform catalog with credentials stripped from every entry. By default it returns entries whose status is in [1 pending, 2 process, 3 active]; pass a statuses array to override. Each returned entry carries id, platform (the slug), plugin_label, logo (inline SVG string), main_markets, countries, country, flag, estimated_costs ({metric, min_cents, max_cents, currency}), api_access, phase, docs_url, plugin_name, status and plugin_generated. The dashboard caches the response for the session and uses it for platform labels, logos and chart colors.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
statuses |
array | No | Not registered in the method contract's fields, but read by the implementation from req.statuses or req.data.statuses. Status codes: 1 pending, 2 process, 3 active, 4 deleted, 5 archived. Defaults to [1, 2, 3]. |
Notes
- Auth:
userclearance. Not private, so an API key can call it. - Credentials on every entry are stripped server side before the response leaves the box, so the catalog is safe to hand to a browser.
- Only
google-adsandmetaare past pending today. Both sit atstatus: 2, which the dashboard renders as a "Beta" chip. Every other entry isstatus: 1and renders under a collapsed "coming soon" disclosure. No entry isstatus: 3. - The catalog holds 42 entries for 40 unique slugs:
taboolaandmercadoeach appear twice. Deduplicate onplatformif you index by slug. - No
min_plan.mcp: false.
generate_ad_creative
Generate Ad Creative
Generates ad copy (headline, primary text, description, CTA) for a campaign and platform in a chosen tone. Google Ads and the rest of the search family (google, microsoft, bing, yahoo, baidu, yandex, naver) get the responsive-search-ad shape with a headline capped at 30 characters and a description capped at 90; every other slug gets the social-feed shape with headline 40, primary text 150, description 30 and a CTA. Context comes from inline fields when the campaign does not exist yet (the create wizard), or from the saved campaign document when app_id is supplied (the editor), in which case the document overrides. The returned shape is { slug, tone, creative }.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.slug |
string | Yes | Platform slug, for example google-ads. Defaults to google-ads if omitted by the implementation. |
data.app_id |
string | No | Not registered in the contract's fields; read by the implementation. When present the campaign document supplies brand, objective and geo. |
data.tone |
string | No | Not registered in the contract's fields; read by the implementation. One of Professional, Friendly, Bold, Playful, Urgent, Luxury. Anything else falls back to Friendly. |
data.brand / data.app_name |
string | No | Not registered; inline brand name when there is no saved campaign. Truncated to 40 characters. |
data.goal / data.objective |
string | No | Not registered; used to pick the benefit line. Recognized values are the six wizard objectives. |
data.geo |
string | No | Not registered; appended to the copy as "for |
data.source |
object | No | Not registered; { value, ref }, used to derive a brand from a URL when no name is given. |
Notes
- Auth:
userclearance. Not private, so an API key can call it. Nomin_plan.mcp: false. - The current implementation is a deterministic, context-aware template generator rather than a model call, so calling it twice in the same second returns the same copy. The phrasing rotates on a three-way cycle keyed to the current second.
- It consumes no AI credits and records no AI usage.
- Generating copy does not save it. Persist it with
update_ad_campaign_creative, then push it to the live ads withlaunch_ad_campaign. - The character caps are enforced again when the ad is built for the network, so oversized copy is clamped rather than rejected.
launch_ad_campaign
Launch Ad Campaign
Creates the campaign in the ad network via its API, always PAUSED, or updates the existing one in place if the campaign has already been launched to that network. Only google-ads and meta are wired; any other slug returns launch not yet wired for <slug>. Network credentials are read server side from environment variables or a gitignored secrets file. Owner-scoped: the caller must own the campaign or be a superuser. On Google it also lazily provisions a per-customer Google Ads client account under the Xuda manager account if the owner does not have one yet. The response includes the network, the created or updated campaign id and resource names, and any non-fatal ad_warning or warning from the ad-group or ad step.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign to launch. |
data.slug |
string | No | Not registered in the contract's fields; read by the implementation. google-ads or meta. Defaults to google-ads. |
Notes
- Auth:
userclearance, owner-scoped. Not private, so an API key can call it. Nomin_plan.mcp: false. - Everything is created paused. Google campaigns are created with
status: 'PAUSED', and Meta campaigns, ad sets and ads are all createdPAUSED. Nothing serves or spends until serving is switched on. - Idempotent per network. A second launch updates the existing campaign in place: the budget is repriced, the ad group is recovered or recreated through a GAQL lookup, and the old ad is removed and a fresh one placed. It self-heals a lost pointer by searching Google for a live campaign whose name starts with the brand, and it pauses then recreates the campaign when the stored campaign type no longer matches the desired type.
- Google shape: a standard SEARCH campaign with a daily
campaignBudget, anENABLEDad group at a 1.00 USD CPC bid, and a responsive search ad built from the saved creative (3 headlines, 2 descriptions, deduplicated and padded). Autopilot triestargetSpend(Maximize Clicks) and falls back tomanualCpcif the account rejects it. - Meta shape: a campaign with an objective mapped from the Xuda goal (
OUTCOME_TRAFFIC,OUTCOME_SALES,OUTCOME_LEADS,OUTCOME_AWARENESS,OUTCOME_APP_PROMOTION,OUTCOME_ENGAGEMENT), an ad set with a daily budget,IMPRESSIONSbilling,LOWEST_COST_WITHOUT_CAPbidding and country targeting, plus an ad creative and an ad when a Facebook Page id is configured. - Dayparting from
settings.scheduleis pushed to Google asAdSchedulecampaign criteria, one criterion per selected weekday with a start and end hour. It is best effort, so a schedule failure never blocks the launch. create_ad_campaignfires this in the background for every selected network, sequentially, right after payment clears. Each run re-reads and saves the campaign document, so do not run two launches for the same campaign in parallel: they would write-conflict.- The stored
budget_splitandbid_strategyare not applied. Each network receives the wholebudget.amount_centsas its daily budget, and bidding is set from thesettings.autopilotflag only. - Budget floors are the networks' own: 10,000 micros on Google, which is 0.01 USD per day, and 100 cents on a Meta ad set daily budget.
- The ad's final URL comes from the campaign's
source.valuewhen that is a valid http or https URL. Otherwise the launcher falls back tohttps://xuda.io.
set_ad_network_status
Set Ad Network Status
Pauses or resumes the live network campaigns (Google and Meta) for a Xuda campaign by walking the campaign's launch records and flipping each launched network. Google resolution is self-healing: it tries the stored resource name, then a name reconstructed from a stored campaign id, then a brand-name search, and it writes the resolved pointer back. It is per-network best effort, so the response results map may contain ok, not configured, no matching campaign found, or an error string per network. Owner-scoped.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign whose network status to flip. |
data.status |
string | No | Not registered in the contract's fields; read by the implementation. active resumes, anything else pauses. A boolean data.paused is also accepted. |
Notes
- Auth:
userclearance, owner-scoped. Not private, so an API key can call it. Nomin_plan.mcp: false. - This method touches the ad networks only. It does not change the campaign's own
ad_statusand does not touch Stripe. The dashboard's Active / Paused switch callsset_ad_campaign_statusfirst for the local status and Stripe collection, then this method for the real networks. An API key can only do the second half, because the first is session only. - The Stripe billing webhooks call this method internally to stop and resume serving when an invoice fails or is recovered.
- A network that was never launched is reported as
no matching campaign foundrather than treated as an error for the whole call.
get_ad_campaign_report
Get Ad Campaign Report
Pulls live daily metrics from each launched network, writes them into the campaign's report.series, and returns { series, updated_at }. The series shape is { days: ['YYYY-MM-DD', ...], platforms: [{ slug, clicks[], impressions[], spend_cents[], conversions[] }] }, one array element per day. Meta comes from the campaign Insights edge with time_increment: 1; Google comes from a GAQL query over campaign segmented by date, selecting clicks, impressions, cost micros and conversions. When nothing has launched yet the method returns { code: 0, data: { series: null } } so the dashboard keeps showing its labeled sample data. Owner-scoped.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign to report on. |
data.days |
number | No | Not registered in the contract's fields; read by the implementation. Clamped to 1 to 30, default 14. |
Notes
- Auth:
userclearance, owner-scoped. Not private, so an API key can call it. Nomin_plan.mcp: false. - Reporting is pull based. There is no inbound webhook from Google or Meta, so a call to this method is what refreshes the numbers.
- Meta conversions are counted from actions matching purchase, lead, complete_registration or submit_application.
- Read the numbers from
report.series. The scalar block seeded at create time (report.spend_cents,impressions,clicks,conversions,last_updated_ts) is never updated by anything, so it stays at zero. - The same 30-day window is what the budget-enforcement cron refreshes when it checks a campaign against its cap.
provision_google_ads_account
Provision Google Ads Account
Creates a new Google Ads client account under the Xuda manager account for the customer and stores the resulting customer id on their account document as google_ads_customer_id, plus a google_ads_provisioned_at timestamp. One account per customer, reused: if the account already has an id, the method returns it with existing: true and makes no API call. The new account is created with descriptive name Xuda - <label>, currency USD and timezone America/New_York, and bills to the manager's consolidated billing. This is the agency core: the customer never touches an ad-platform login.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | No | A campaign to resolve the owning customer from. If omitted, the calling user's own account is provisioned. |
data.name |
string | No | Not registered in the contract's fields; read by the implementation. Label used in the Google account's descriptive name, truncated to 60 characters. Falls back to the campaign name, then the account email, then the uid. |
data.uid |
string | No | Not registered in the contract's fields; read by the implementation as a fallback when the request carries no authenticated uid. |
Notes
- Auth:
userclearance. Not private, so an API key can call it. Nomin_plan.mcp: false. - Requires
developer_token,client_id,client_secret,refresh_tokenandlogin_customer_idto be configured on the box. When any of those is missing the method returns which ones. - You rarely need to call this.
launch_ad_campaignruns the same provisioning lazily on the first Google launch, and a provisioning failure there is non-fatal: the launch falls back to the shared credentials account. - It is not surfaced anywhere in the dashboard. The API is the only place it can be triggered explicitly.
get_account_advertising
Get Account Advertising
Returns the caller's advertising campaigns as { rows: [{ id, value }] }, the same bucketed shape the dashboard uses for deployments and VPS. This is the method behind the Campaigns list and its Refresh button.
Availability: API key
Parameters
This method takes no parameters. Scope comes from the authenticated uid.
Notes
- Auth:
userclearance. Not private, so an API key can call it. Nomin_plan. mcp: true. This is the only AI Advertising method exposed as an MCP tool.- Backed by a Mango query for
{ app_uId, app_type: 'advertising', docType: 'app' }with a limit of 1000 campaigns. - A superuser sees every campaign across all accounts.
create_ad_campaign
Create Ad Campaign
Creates an advertising campaign and charges the prepaid budget plus the 10 percent automation fee to the user's saved card through Stripe. The order of operations is create the document, then charge, then reflect the result, so a user is never charged for a campaign that failed to persist; on a charge failure the document is kept and marked payment_failed. A daily budget becomes a monthly Stripe subscription whose first invoice is charged immediately, and a lifetime budget becomes a single one-off charge. After payment clears the method fires a background sequential launch to every selected network and returns { app_id, ad_status, launching: true, payment, billing } immediately.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_name |
string | Yes | Display name for the campaign. |
data.providers |
array | Yes | Ad networks to run on, for example ['google-ads','meta']. The registered description gives the example ['google','meta']; the dashboard sends catalog slugs, which are google-ads and meta. |
data.budget |
object | Yes | Budget object, for example { amount_cents, currency, mode }. mode is daily (default) or lifetime. |
data.card_id |
string | Yes | Stripe card or payment-method id to charge. |
data.terms_accepted |
boolean | Yes | User accepted the advertising terms. Rejected with terms must be accepted if falsy. |
data.source |
object | No | Not registered in the contract's fields; read by the implementation. { type: 'xuda_landing' | 'url' | 'free_text', value, ref }. |
data.provider |
string | No | Not registered; legacy single-provider fallback when providers is absent. |
data.goals |
object | No | Not registered; { objective, audience: { geo, age_range, gender } }. |
data.creative |
object | No | Not registered; the shared creative. |
data.creatives |
object | No | Not registered; per-platform creatives keyed by slug. |
data.budget_split |
object | No | Not registered; percentage per platform. Stored only, not applied to network budgets. |
data.bid_strategy |
string | No | Not registered; stored only. |
data.ad_budget_cents |
number | No | Not registered; alternative to budget.amount_cents. |
Notes
- Auth:
userclearance,private: true, so a signed-in dashboard session only. An API key cannot create a campaign. Nomin_plan. - Money: the automation fee is a flat 10 percent of the ad budget. For a daily budget,
monthly_budget_centsis the daily amount times 30.4,monthly_fee_centsis 10 percent of that, and their sum is the first invoice. For a lifetime budget it is one charge of budget plus 10 percent. - The Stripe product and price are created inline per campaign. There are no pre-minted price ids to look up.
- Stripe refuses any amount under 50 cents, on a one-off charge and on a subscription alike, with
amount below Stripe minimum (~$0.50). - After the charge the campaign sits at
ad_status: 'pending_review'with alaunch_started_tswhile the background launches run. The dashboard polls every 3 seconds for up to roughly 45 seconds until per-network launch records land. - The launches are sequential by design, because each one re-reads and saves the same document.
create_ad_campaignruns the Xuda Verify gate for thecampaign_setupproduct, a level 3 gate. The shipped policy hasshadow_mode: true, so the gate reports what it would do and always allows. A box can turn enforcement on throughconfig.verify.enforce_from_level.- Campaigns are exempt from the membership plan ladder. Plan validation short-circuits for the
advertisingapp type and returnsmembership_plan: 'advertising_exempt', so a campaign is creatable on the Free plan.
cancel_ad_campaign
Cancel Ad Campaign
Cancels a campaign: it deletes the recurring Stripe subscription (best effort, prorate: false) and sets ad_status: 'cancelled' plus billing.status: 'canceled'. Owner-scoped.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign app to cancel. |
Notes
- Auth:
userclearance,private: true, owner-scoped. Nomin_plan. - It does not pause the live network campaigns. If the campaign is serving, stop it first with
set_ad_network_status, or the ads keep running inside Google and Meta. - It issues no refund. The campaign document carries a
refunded_centsfield that nothing increments, so any refund is a manual Stripe operation. - The current billing period is already prepaid, and cancellation is not prorated.
get_ad_campaign_billing
Get Ad Campaign Billing
Returns the campaign's billing summary for the Billing tab: the campaign's own billing and payment blocks, the saved card_id, the live Stripe subscription (id, status, paused flag, cancel-at-period-end, period start and end timestamps, amount, currency, interval) and up to 24 invoices (id, number, status, paid, amount, currency, created, period start and end, hosted invoice URL, PDF URL). A one-off campaign returns its single charge with no subscription. Owner-scoped.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign app to read billing for. |
Notes
- Auth:
userclearance,private: true, owner-scoped. Nomin_plan. - This method reports what was billed. For what was actually spent on the networks, call
get_ad_campaign_report. - The
billingblock it returns is{ mode: 'subscription' | 'one_off', interval, monthly_budget_cents, monthly_fee_cents, monthly_total_cents, currency, status, current_period_start_ts, current_period_end_ts }.
set_ad_campaign_card
Set Ad Campaign Card
Points a campaign's recurring subscription at a different saved card. It updates the Stripe subscription's default_source, also updates the Stripe customer's default source, and writes card_id onto the campaign. Owner-scoped.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign app to update. |
data.card_id |
string | Yes | Stripe card or payment-method id to bill going forward. |
Notes
- Auth:
userclearance,private: true, owner-scoped. Nomin_plan. - Because it also moves the customer's default source, a card change made here affects future charges that fall back to the customer default.
set_ad_campaign_status
Set Ad Campaign Status
Sets a campaign's own ad_status. Allowed values are active, paused, pending_review and cancelled; anything else is refused with invalid status. For active and paused it also mirrors the status onto every per-network launch record so the header toggle does not visibly flip back, records ad_paused_reason as user or null, and pauses or resumes Stripe collection on the subscription. Owner-scoped.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign app to update. |
data.status |
string | Yes | New ad_status value: active, paused, pending_review or cancelled. |
Notes
- Auth:
userclearance,private: true, owner-scoped. Nomin_plan. - This method does not flip the real network campaigns. The dashboard always follows it with
set_ad_network_status, and so should any other caller. - Pausing pauses Stripe collection with
pause_collection: { behavior: 'void' }, so a paused campaign stops billing as well as stops serving. Resuming lifts it. ad_paused_reasonis what keeps automation from fighting a human. A pause made here is stampeduser, the budget cron stampsbudget, and the Stripe webhooks stampbilling. Automatic resume only ever restarts campaigns that the same automation paused.
update_ad_campaign_budget
Update Ad Campaign Budget
Changes a recurring campaign's daily budget. It recomputes the daily figures on the campaign (budget.amount_cents, ad_budget_cents, fee_cents) and the monthly block (monthly_budget_cents at daily times 30.4, monthly_fee_cents at 10 percent, monthly_total_cents), then reprices the Stripe subscription with proration_behavior: 'none' so the new amount bills at the next cycle. Owner-scoped.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign app to update. |
data.amount_cents |
number | Yes | New daily budget in cents. Must be greater than 0. |
Notes
- Auth:
userclearance,private: true, owner-scoped. Nomin_plan. - Refused for one-off lifetime campaigns with
budget changes apply to recurring campaigns only, and refused for cancelled campaigns. - This changes the billed budget only. The new daily budget does not reach Google or Meta until the campaign is deployed again with
launch_ad_campaign. - The current cycle is already prepaid, so the new price takes effect on the next billing date.
- The dashboard's Edit budget dialog enforces a floor of 1 dollar per day on its own. The hard floors below that are Stripe's 50 cent minimum and each network's own budget floor.
update_ad_campaign_creative
Update Ad Campaign Creative
Persists edited ad copy. Only the keys headline, primary_text, description, cta and image_b64 are accepted; everything else is dropped. Per-platform creative is stored under creatives[slug], and when the slug matches the first provider it is mirrored to the shared creative for the list and the preview. Passing no slug, or _default, writes the shared creative directly. Owner-scoped.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign app to update. |
data.creative |
object | Yes | Creative object { headline, primary_text, description, cta, image_b64 }. |
data.slug |
string | No | Not registered in the contract's fields; read by the implementation. Platform slug to scope the creative to. _default or absent writes the shared creative. |
Notes
- Auth:
userclearance,private: true, owner-scoped. Nomin_plan. - Saved copy only reaches the live ads on the next deploy. Call
launch_ad_campaignfor each network afterward. - Respect the per-network caps when you write your own copy: 30-character headline and 90-character description on the search family, and 40 / 150 / 30 plus a CTA on feed networks. Anything longer is clamped when the ad is built.
update_ad_campaign_settings
Update Ad Campaign Settings
Persists campaign settings with a shallow merge. The dashboard sends the whole settings object: autopilot (boolean), budget_rules ({ monthly_cap_cents, pacing_alert_pct, auto_pause_enabled, auto_pause_cpa_cents }), schedule ({ days: 0-6 array, hour_start, hour_end, timezone }) and utm ({ enabled, source, medium, campaign }). Owner-scoped.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
data.app_id |
string | Yes | The campaign app to update. |
data.settings |
object | Yes | Settings object to shallow-merge into the campaign's settings. |
Notes
- Auth:
userclearance,private: true, owner-scoped. Nomin_plan. monthly_cap_centsandpacing_alert_pctare read by the budget-enforcement cron. The cap is genuinely enforced; the pacing percentage raises a one-per-period marker. The pacing alert defaults to 80 percent.scheduleis pushed to Google as ad-schedule criteria on the next create, so a schedule change needs a deploy to take effect.- Switching
autopilotchanges how the Google campaign bids, and the campaign is rebuilt on the next deploy when the desired type no longer matches the stored one. auto_pause_enabledandauto_pause_cpa_centsare stored but not read by any enforcement code today. Do not depend on them to stop a campaign.
Errors
Refusals arrive as readable messages on the CPI envelope rather than as a numbered catalog. These are the ones this product raises.
| Message or code | Raised by | When |
|---|---|---|
terms must be accepted |
create_ad_campaign |
data.terms_accepted is falsy. |
amount below Stripe minimum (~$0.50) |
create_ad_campaign |
The charge or the subscription amount is under 50 cents. Both paths carry the same floor. |
invalid status |
set_ad_campaign_status |
data.status is not active, paused, pending_review or cancelled. |
budget changes apply to recurring campaigns only |
update_ad_campaign_budget |
The campaign is a one-off lifetime campaign. Cancelled campaigns are refused too. |
launch not yet wired for <slug> |
launch_ad_campaign |
The slug is anything other than google-ads or meta. |
{ code: -2, data: 'app_type error' } |
create_ad_campaign |
The box's configuration does not list advertising as a creatable standalone app type. |
| A list of missing credential names | provision_google_ads_account |
Any of developer_token, client_id, client_secret, refresh_token or login_customer_id is not configured. |
Ownership and type. Every campaign-scoped method is owner-scoped: the caller must own the campaign, and a superuser is the only exception. Every one of them also refuses a document whose app_type is not advertising.
Per-network results rather than a hard failure. set_ad_network_status reports per network in a results map, whose values are ok, not configured, no matching campaign found, or an error string. One bad network does not fail the call.
Non-fatal warnings on launch. launch_ad_campaign returns ad_warning, budget_warning or warning when the campaign was created or updated but a later step (ad group, ad, budget or ad schedule) had a problem. Treat the presence of a warning as "campaign exists, one piece needs attention", not as a failure.
Payment failure is not method failure. A failed charge in create_ad_campaign keeps the campaign and marks it payment_failed rather than discarding the work.
One plan gate does bite this product indirectly. Inviting a teammate to a campaign goes through add_admin_member in the team module, which carries min_plan: "team". The platform plan gate exempts websites, not advertising, so on a plan below Team the invite is refused with a plan-gate message even though the campaign itself is plan-exempt.
Webhooks
This product publishes no outbound webhooks. Reporting is pull based: call get_ad_campaign_report to refresh the numbers. Google and Meta send nothing inbound either.
The webhooks that do affect a campaign are Stripe's, handled inside Xuda:
| Stripe event | Effect on the campaign |
|---|---|
invoice.payment_failed |
Network serving is stopped and the pause is stamped ad_paused_reason: 'billing'. |
invoice.paid, invoice.payment_succeeded |
Serving resumes, but only for campaigns that billing itself paused. A campaign paused by the user or by the budget cap stays paused. |
Rate Limits And Recurring Work
There is no per-method rate limit on the advertising methods themselves. The limits you will meet in practice are the ad networks' own API quotas, which surface as errors or warnings from launch_ad_campaign, set_ad_network_status and get_ad_campaign_report.
| Recurring work | Cadence |
|---|---|
| Budget-enforcement sweep | Every 30 minutes by default, overridable per box. Runs on the active primary node only. |
| Dashboard launch poll after create | Every 3 seconds, for up to roughly 45 seconds |
The budget sweep is the one automated behavior in the product. For every campaign at ad_status: 'active' it refreshes 30 days of spend, compares it to the cap (the prepaid monthly budget, tightened by the customer's own monthly cap when that is lower), pauses the live network campaigns and stamps ad_paused_reason: 'budget' when the cap is reached, and otherwise raises a one-per-period pacing marker at the customer's pacing percentage.
Idempotency
- Launching twice is safe.
launch_ad_campaignis idempotent per network. A second launch updates the existing campaign in place rather than creating a duplicate, and it will adopt a live campaign whose name starts with the brand if the stored pointer was lost. - Do not launch the same campaign in parallel. Each launch re-reads and saves the campaign document, so concurrent runs write-conflict. Push networks one at a time, which is what both the dashboard and the post-payment background launcher do.
- Provisioning is once per customer.
provision_google_ads_accountreturns the existing id withexisting: trueand makes no API call when the account already has one. - Creating a campaign is not idempotent.
create_ad_campaigncharges money. There is no request key to deduplicate on, so never retry it blindly after a timeout; read the campaign list withget_account_advertisingfirst. - Copy and settings writes are last-write-wins.
update_ad_campaign_creativekeeps only the five accepted keys, andupdate_ad_campaign_settingsshallow-merges the object you send.
Plan Gates And Money
There is no plan gate on any of the fifteen methods. None carries a min_plan, and plan validation short-circuits for the advertising app type with membership_plan: 'advertising_exempt', so campaigns work on every membership plan including Free. The only thing you pay for is the campaign.
| Rule | Value |
|---|---|
| Automation fee | A flat 10 percent of the ad budget, on both budget modes |
| Daily budget billing | Monthly, at the daily amount times 30.4 days, plus the 10 percent fee, as a Stripe subscription whose first invoice is charged at create |
| Lifetime budget billing | One one-off charge of budget plus 10 percent |
| Stripe minimum | 50 cents, on one-off charges and subscriptions alike |
| Budget change proration | None. A new daily budget bills from the next cycle |
| Cancellation proration | None. The current period is already prepaid |
| AI credits | Not consumed. generate_ad_creative records no AI usage |
Stripe products and prices are created inline per campaign, named Xuda Ad Campaign - <name>, so there is no price list to mint or look up before you integrate.
Other Limits And Defaults
| Setting | Value |
|---|---|
| Report window | 1 to 30 days, default 14 |
Invoices returned by get_ad_campaign_billing |
Up to 24 |
Campaigns returned by get_account_advertising |
Up to 1000 |
| Search-family ad copy | Headline 30 characters, description 90 |
| Feed ad copy | Headline 40, primary text 150, description 30, plus a CTA |
| Brand string used in generated copy | Truncated to 40 characters |
| Google account label on provisioning | Truncated to 60 characters |
| Google campaign budget floor | 10,000 micros, that is 0.01 USD per day |
| Meta ad set daily budget floor | 100 cents |
| Google ad group CPC bid | 1.00 USD |
| Responsive search ad built per launch | 3 headlines, 2 descriptions, deduplicated and padded |
| Currencies offered in the wizard | USD, EUR, GBP |
| Wizard budget slider | 5 to 500 dollars, in steps of 5 |
| Tones | Professional, Friendly, Bold, Playful, Urgent, Luxury. Anything else falls back to Friendly |
| Goals | Website traffic, Sales and conversions, Lead generation, Brand awareness, App installs, Engagement |
| Google Ads API version | Pinned, v21 by default |
| Meta Marketing API version | Pinned, v21.0 by default |
What Is Not Wired Yet
Build against what exists. These are honest gaps in the current implementation, and none of them will silently start working.
- Two networks only.
google-adsandmetaare wired for launch, pause, resume and reporting. The other 38 catalog slugs are listed as coming soon and are refused bylaunch_ad_campaign. - The creative generator is a template engine, not a model call. It is context-aware and respects every network's character limits, but it is deterministic within the same second and consumes no AI credits.
- There is no optimization engine. The only automated behavior is the budget sweep described above. Nothing moves budget between platforms, narrows an audience, pauses a single channel or writes an optimization log.
budget_splitandbid_strategyare stored, not applied. Both launchers use the wholebudget.amount_centsas each network's daily budget, and bidding comes fromsettings.autopilotonly.auto_pause_enabledandauto_pause_cpa_centsare stored, not read. No enforcement code consumes them.- The scalar report block is never filled. Read
report.seriesfromget_ad_campaign_report, notreport.spend_centsand its siblings. - There is no refund path in code.
cancel_ad_campaignends the subscription without prorating,refunded_centsstays at 0, and any refund is a manual operation.
A Note On The Rest Of The Surface
Beyond the fifteen registered methods, a few things exist that you cannot call:
- The budget-enforcement sweep is a scheduled internal function. It takes no request and is not reachable over HTTP.
- An internal catalog gate returns a full platform entry including credentials only for a platform at
status: 3. Nothing in the product calls it, and no catalog entry carries that status today. - The Stripe helpers that charge a campaign, create and reprice its subscription, pause collection, change its card, read its billing and cancel it are internal to the billing module. The advertising methods above are the supported way to reach that behavior.
Two related surfaces belong to other products rather than to this one:
- Campaign team sharing uses the generic app team methods (
add_admin_member,remove_admin_member,resend_access_invitation) withaccess_type: 'admin'. They are not advertising-specific, andadd_admin_membercarries the Team plan gate noted under Errors. - Campaign ownership transfer uses the generic transfer methods. Advertising is a transferable app type, and confirming a transfer moves the Stripe subscription to the recipient's card before ownership flips, so a billing failure leaves the transfer pending and retryable.