Skip to content
Docs

Run ads from Codex

Codex-style agents get a real ad account through the hosted MCP server or the REST API. They launch campaigns and read performance.

2 min readOur judgmentUpdated
On this page

A Codex-style agent launches ads by calling the public Adprime Zero API, not by writing a plan that never becomes an object.

This guide covers how a code-capable agent discovers the service, stores a key, stops at a funding URL, and iterates from reports.

Why a code agent is a good fit

Codex already lives in a terminal and can call MCP tools. Add https://mcp.adprimezero.com/mcp as a remote MCP server and sign in once in the browser; the agent then reads the tool list instead of guessing route names. REST API reference has the REST map for anything scripted.

If the build you run cannot open a browser for MCP sign-in, create a key on the dashboard API keys page and send it as Authorization: Bearer ak_..., to the MCP URL or to the REST API. Direct REST clients need a normal User-Agent header, for example your-agent-name/1.0. Anonymous runtime defaults can be rejected before the request reaches the API.

The MCP tools cover get_account, request_prepay_link, targeting, creative, campaign launch and pause, conversion, and performance. Every tool call that changes account state goes through the public REST API. There is no hidden agent permission system.

Launch sequence

  1. Connect the account (MCP sign-in, or a key kept in the user's secret storage).
  2. Collect landing URL, offer, geography, daily budget, and image assets from the user. Do not invent a click URL.
  3. pre_check_creative, then submit_creative with headline, description, expected content, and disclosure. Poll get_creative until it is approved.
  4. discover_segments when the user asked for an audience. Use returned ids. Show estimated data CPM.
  5. create_targeting, create_campaign, then activate_campaign.
  6. If balance is missing, request_prepay_link, hand the user the link, and poll get_funding_intent_status. Do not collect cards.
  7. After activation, list_campaign_performance and get_beeswax_reporting_status (reporting freshness).

Copy a campaign when the next test would contaminate the first. Rotate creatives with add_campaign_creative and replace_campaign_creative. The last active creative cannot be paused or removed.

What Codex must not do

It must not write exchange campaign ids by hand. It must not embed the API key in a browser pixel. It must not treat generated_at as reporting freshness. It must not optimize on click-through rate. It must not enable conversion-based optimization until an event exists, a test fire has succeeded, and the campaign is linked.

If the environment is Cursor instead of Codex, use Launch ads from Cursor. If you are still choosing how any agent connects, use Connect your AI assistant and launch. The daily operating loop after attach is How an agent buys ads.