How to get ad reports with OpenAI Codex

Codex turns ad results into a dated markdown file: it pulls spend and results for the campaigns it runs through Hypesonic, says what to scale, cut and test, and can run unattended every week with codex exec.

By Grace Kong·Updated ·5 min read

Get a weekly ad report from your agent

TL;DR

  • Setup is codex mcp add Hypesonic --url https://www.hypesonic.com/mcp and codex mcp login Hypesonic. Scheduled runs load project MCP servers only in trusted projects (Codex docs, Nov 2026).

  • codex exec "..." -o reports/latest.md writes the final message to a file from cron or CI, in a read-only sandbox by default.

  • Since January 12, 2026, Meta's Insights API no longer returns 7-day or 28-day view attribution, so view-through conversions in those windows drop out.

  • Meta keeps totals for 37 months, but unique counts and hourly breakdowns for only 13 months and frequency breakdowns for 6.

  • US Facebook CPM (cost per 1,000 impressions) rose from $18.20 in October 2026 to $20.85 in November, about 15%, as holiday advertisers entered the auction.

Set up Hypesonic in Codex

Add https://www.hypesonic.com/mcp as a remote MCP server named Hypesonic and sign in once; the CLI, IDE extension and ChatGPT desktop app share it.

codex mcp add Hypesonic --url https://www.hypesonic.com/mcp
codex mcp login Hypesonic

For scheduled runs, put the server in the project's .codex/config.toml and mark the project trusted: Codex loads project-defined MCP servers for codex exec only in trusted projects, and exits with an error if a required MCP server fails to start (Codex docs, non-interactive mode). Run codex mcp login Hypesonic once on that machine so the job has a valid sign-in (Codex docs, MCP). Setup for every agent: connect the Hypesonic MCP.

The exact request, interactive and scheduled

Ask once in the terminal; when the report is right, put the same words in a scheduled job.

Use Hypesonic to pull last week's spend and results for our Meta campaigns.
Rank ads by cost per purchase.
Break down the top 3 and bottom 3 ads: what each shows and says in the first seconds.
Write ./reports/$(date +%F).md: what to scale, what to cut, 3 tests for next week.
State the attribution setting the results use.

Unattended, every Monday at 8 am:

0 8 * * 1  cd ~/marketing && codex exec "Use Hypesonic to write this week's Meta report as in reports/TEMPLATE.md" -o reports/latest.md

codex exec prints progress to stderr and only the final message to stdout; -o writes that final message to a file, and --json switches stdout to JSON Lines. It runs in a read-only sandbox by default, which suits a job that only reads results (Codex docs).

What Codex does, step by step

Pull, rank, break down, then write.

  1. Pulls spend and results for every ad it runs through Hypesonic. Meta is the example here; TikTok, Pinterest, Reddit, LinkedIn, streaming TV and billboard campaigns report the same way.
  2. Ranks the ads by the number you name, such as cost per purchase.
  3. Breaks down the top and bottom ads with Hypesonic's Ad Analysis API, which watches each one and describes what it shows and says.
  4. Writes the verdict: what to scale, what to cut, what to test.
  5. Saves the file and compares it with last week's report in the same folder.
  6. Reports what the run cost from spend_get. Any step that costs money gets a quote with estimate: true first, and your approval mode decides whether Codex asks.

What you get back

A markdown report your team can read in GitHub, Slack or an editor.

  • Top and bottom ads with spend, cost per purchase and click-through rate.
  • A short note on what the winners have in common, from the ad breakdowns.
  • Three actions: scale, cut, test, each with the ad names.
  • A dated file, so trends show up across weeks without a dashboard.

Benchmarks to read the report against

A number only means something next to a baseline.

MetricBenchmarkSource
Facebook click-through rate (CTR), traffic campaigns1.93% (cost per click, or CPC, $0.60)LocaliQ
Facebook CTR, lead campaigns2.70% (CPC $1.80)LocaliQ
Facebook lead conversion rate8.54% of clicksLocaliQ
US Facebook CPM$18.20 (Oct 2026) to $20.85 (Nov 2026)Birch
TikTok median CPM$4.08Quimby, citing Triple Whale
TikTok median cost per purchase$17.07Quimby, citing Triple Whale

The CPM jump from October to November is about 15% (our math): Black Friday advertisers enter the auction, so a weekly report in late November should not read a higher CPM as an ad problem.

Data limits that change your numbers

Meta changed what its reporting API returns in 2026.

  • View attribution: from January 12, 2026 the Insights API stopped returning the 7-day view and 28-day view windows (Meta for Developers). Reports built on them will show fewer conversions.
  • History: total values stay available for up to 37 months, but unique-count fields and hourly breakdowns go back 13 months, and frequency breakdowns 6 months.
  • Practical rule: pick one attribution setting, write it in the report, and keep it the same every week.

Where Codex is strong and weak for reporting

Strong at repeatable files; not a live dashboard.

  • Strong: codex exec runs from scripts and scheduled jobs and writes the report to a file you choose.
  • Strong: reports live next to last week's, so "what changed?" is a file comparison.
  • Weak: unattended runs cannot answer an approval prompt; keep scheduled jobs to reporting, and launch changes interactively.
  • Weak: no charts unless you ask Codex to write a script that draws them.

Questions

Can Codex pull my Facebook ad data?

Yes, for the campaigns it runs through Hypesonic. Codex pulls spend and results from Meta and writes the report to a file.

How do I schedule an ad report with Codex?

Use codex exec with your prompt from cron or a CI job, and -o to write the final message to a file. Project MCP servers load only in trusted projects.

Why do my Meta conversions look lower in API reports?

Since January 12, 2026 the Insights API no longer returns 7-day and 28-day view attribution, so view-through conversions in those windows drop out.

How far back can I report on Meta ads?

Total values go back up to 37 months. Unique-count fields and hourly breakdowns go back 13 months, and frequency breakdowns 6 months.

Sources

  1. 1OpenAI Codex docs, MCP · accessed Nov 30, 2026
  2. 2OpenAI Codex docs, non-interactive mode · accessed Nov 30, 2026
  3. 3Meta for Developers, Ads Insights API metric availability updates · Oct 16, 2025
  4. 4LocaliQ, Facebook advertising benchmarks · Sep 2026
  5. 5Birch, Facebook advertising costs · Nov 2026
  6. 6Quimby Digital, TikTok ad costs 2026 (Triple Whale data) · Nov 2026

Get a weekly ad report from your agent

Keep reading