Ads: agent tools and API boundaries

Managed Ads exposes company-scoped ads_* tools inside the connected Gateway. Start with ads_workspace and inspect the current policy, readiness, generation capabilities, and funding state. The executing company conversation or task supplies authority; standalone agents do not gain company Ads access by passing a company ID.

This guide describes the implemented product tool and first-party application boundaries. It does not register Ads operations in the public Agent API or make internal routes callable with a public agent bearer token.

Choose the correct interface

  • Gateway ads_* tools: verified company conversation/task context, typed arguments, action policy, and durable approval continuation.
  • Desktop Ads HTTP: the first-party authenticated application/device boundary. Its base path is shown below.
  • Dashboard Ads HTTP: a verified HttpOnly member session and exact-origin CSRF checks. Its base path is shown below.
  • Internal Gateway-to-Site routes: signed server/runtime requests. These are not public client APIs and do not accept public agent bearers as runtime authority.
  • Public Agent API: use its current capabilities and generated operation registry. An internal Ads route or tool name does not establish public API availability.
Text
Desktop:   /api/auto/companies/:companyId/ads
Dashboard: /api/dashboard/v1/companies/:companyId/ads
Public:    /api/agent/v1

Site resolves tenant/company scope, membership, capabilities, current policy, billing, and provider readiness. Never put tenant identity, company authority, provider secrets, approval decisions, or billing evidence into an Ads tool's business arguments.

The Dashboard's browser bridge dispatches chat and schedule execution to the connected Gateway. Saving a command does not prove its execution, and disconnection does not automatically select a Site-hosted agent.

Read the tool schema before calling

Every registered tool exposes JSON Schema generated from its current Zod request schema. Objects are strict: misspelled and extra fields are refused. Tool names, required fields, units, enums, and available media specifications come from the running tool descriptor and ads_workspace, not from a guessed provider request.

A typical sequence is:

  1. ads_workspace, then ads_providers and the selected provider's readiness tools.
  2. ads_creative_grounding for relevant activities and communications; follow all cursors needed for the requested scope.
  3. ads_creative_brief, then ads_creative_revision and ads_creative_edit to persist the complete composition.
  4. ads_creative_generate for an admitted source request; ads_creative_status and ads_creative_progress for its actual state.
  5. ads_creative_compose when supported, then the quality-review tools for the exact produced revision.
  6. Provider-appropriate campaign review, proposal, approval, and delivery operations.
  7. Status and report tools to reconcile delivery, costs, and results.

Each operation still checks current authority. A successful read or an approved creative is not permission to publish.

JSON: create a brief

Tool: ads_creative_brief. The instruction below requests planning; it does not authorize spending.

JSON
{
  "idempotencyKey": "demo-launch-brief-001",
  "instruction": "Plan a vertical ad using approved company product captures. Save a truthful storyboard and CTA for review before producing missing media.",
  "format": "video"
}

Read the returned creative's current revision. Before generating, save the complete composition with the supported edit schema, preserving existing fields, file references, hashes, rights, and provenance. An omitted field is not a patch. Select grounding IDs returned by the company evidence tools; do not invent IDs or rights assertions.

YAML: readable action plan

This is a documentation representation of separate tool calls, not a YAML import endpoint or an executable workflow file. Invoke each tool with its JSON arguments through the registered Gateway tool interface. Replace example identifiers with exact returned values.

YAML
actions:
  - tool: ads_workspace
    arguments: {}
  - tool: ads_creative_revision
    arguments:
      creativeId: creative-from-brief
      revision: 1
  - tool: ads_creative_status
    arguments:
      creativeId: creative-from-brief
      limit: 30
  - tool: ads_creative_progress
    arguments:
      jobId: job-from-status
      afterSequence: 0
      limit: 30

Continue status/history pagination using returned cursors and sequence values. Reading an exact historical revision must not silently substitute the latest revision.

Generate only from current capabilities

ads_creative_generate without generation prepares an unpaid canonical job. A funded generation adds the exact generation.kind, model, prompt, and validated spec. Use the capability response's model and specification; it includes the current generation mode, placement, source requirements, and pricing information.

A source reference contains creativeId, immutable revision, fileId, sha256, and role. It must identify a saved, rights-cleared company asset. A local path, public URL, signed URL, or invented hash is not a substitute.

The same idempotency key cannot change the model, prompt, sources, placement, duration, resolution, or audio. A known or uncertain paid submission is reconciled, never regenerated automatically. Read generationFunding before another paid request. A funding hold is not cleared by switching providers or creating a new key.

Generate one shot at a time per creative. Each generation targets the creative's current revision and produces the next one, so while one is running Site refuses another paid generation for the same creative with generation_in_progress (HTTP 409) before any provider call or charge; its message names the running job. Wait for that job, then generate the next shot against the revision it produced.

Produced media enters a new revision for validation. The provider completing a source shot is not proof that a full ad was assembled or approved.

JSON: bounded Whop automation

Tool: ads_whop_automation_authorize. This illustrative USD request caps the period's combined delivery and automation cost at $120 and supplies a $5 delivery safety reserve. The server derives admissible provider spend and fee reservation; it does not simply permit $120 of provider delivery. Replace the example campaign, revision, end time, and intent with reviewed current values before invoking it.

JSON
{
  "campaignId": "campaign-from-review",
  "expectedCampaignRevision": 3,
  "idempotencyKey": "demo-whop-period-001",
  "combinedLimitMicros": 120000000,
  "deliveryReserveMicros": 5000000,
  "endsAt": "2030-01-15T18:00:00.000Z",
  "acceptedFeeVersion": "whop-autonomy-20pct-v1"
}

Micros values are integer millionths of USD: 1000000 is $1. Fields ending in Minor use the specified currency's minor unit; do not copy a micros value into a minor-unit field. Revisions and money are bounded safe integers, never floating-point dollar strings.

The authorization requires current campaign-change policy and reserves fee credits under one immutable intent. It does not publish or resume delivery. Whop bills provider delivery directly; Neotask charges 20% of verified autonomous provider cost incrementally in usage credits. Manual Whop management has no automation fee. Managed Meta instead uses customer consumption = provider cost / 0.8. Read the billing guide.

Use ads_whop_automation_status with campaignId and feeContract: "ads-fee-rate-v1" to read current, latest, and every item in outstandingFees, each with the feeVersion and feeRateBasisPoints it recorded, plus the quote a new period accepts. Accept that exact quote as acceptedFeeVersion and acceptedFeeRateBasisPoints. A stop request identifies an exact authorizationId and expectedRevision, with a stable idempotencyKey. A returned stopping state is not confirmed manual takeover. requestedPeriod identifies the period actually requested, including a replay after a later period starts.

Fee recovery uses ads_whop_automation_recover_fee with the exact server-observed authorizationId, expectedRevision, positive expectedUncollectedFeeMicros, stable key, and accepted fee version. It requires explicit durable funding approval even when normal policy is automatic. Changed debt or revision requires a fresh review. It settles that debt from available unreserved credits; it does not buy credits, refill a wallet, or resume delivery.

A campaign Neotask runs on the company's own Meta account carries a Neotask fee term when the tenant's rate is above zero. ads_meta_fee_status with campaignId returns the current quote and the campaign's term: its recorded rate, maximumFeeMicros, charged feeMicros, and uncollectedFeeMicros. Unpaid fee pauses delivery. ads_meta_fee_recover pays it with the exact termId, positive expectedUncollectedFeeMicros, a stable key, and the term's acceptedFeeVersion and acceptedFeeRateBasisPoints, under the same explicit funding approval. It pays from available usage credits only and never resumes delivery; resuming holds new fee coverage.

Reports, groups, and exact identity

Keep providerConnectionId, provider, advertiser account, network, currency, and spend basis together. Meta campaign tools use the current Meta binding and cannot accept Whop account IDs as replacements.

Group rules are typed conditions, not executable code. Preview before applying; use the current group/resource/membership revisions for changes. Each ad has at most one group membership. Removing membership does not change delivery state.

ads_report_query follows its returned nextCursor with the identical query. Whole-selection totals repeat on pages: use those totals once, append the disjoint dimensions, and retain unavailable-data indicators. Keep provider, currency, timezone, attribution, and spend basis separate.

For a stable complete export, use ads_report_create with the complete query and a stable key, then ads_report_read. Pending jobs do not have completed pages. After completion, follow every nextCursor until null. Resume a failed owned report with ads_report_resume only after repairing its reported cause; report recovery does not resume ad delivery.

Retry and approval contract

  • invalid_request: read the current strict tool schema and correct the request.
  • company_scope_required or runtime_authority_unavailable: restore the company/runtime invocation; do not add authority fields to arguments.
  • approval_required: retain the exact intent while the durable approval flow continues.
  • policy_revision_conflict or idempotency_conflict: reload current state; distinguish a changed intent from a retry of the original one.
  • provider_outcome_unknown: reconcile the original operation before any further paid submission.
  • reauth_required: use the authorized company connection flow, then reread readiness.
  • data_partial or pacing_data_stale: preserve missing/stale evidence; do not infer zero spend or safe admission.

Never treat a lost response, pending command, or an empty preview as proof that no effect occurred. Durable status, current authority, and the original request identity govern recovery.