Create offers and offer codes from Codex
A 7-day free trial for new subscribers, a code for your newsletter, a discount for people who cancelled. Ask Codex and MetaRun stages the right Apple offer type for each audience, with prices for every storefront.
Setup checked October 2026 against Codex MCP docs, non-interactive mode
Connect Codex once
01 · Add the server
Codex sees that MetaRun offers sign-in and starts it straight away, in your browser. Pick read-only or read and change.
codex mcp add metarun --url https://metarun.dev/api/mcp02 · Sign in again later
If the sign-in expires or you disconnected it in MetaRun's settings. --no-browser prints the link instead, for SSH sessions.
codex mcp login metarun03 · Or edit ~/.codex/config.toml
The Codex CLI, the IDE extension and Codex in the ChatGPT desktop app read the same file, so one entry covers all three.
[mcp_servers.metarun]
url = "https://metarun.dev/api/mcp"Prefer a personal access token (scripts, CI)?
Add the server with a token
Mint a personal access token in MetaRun under Settings, MCP. It's shown once and can be revoked any time. Codex reads it from the environment variable you name.
export METARUN_TOKEN="mr_pat_..."
codex mcp add metarun --url https://metarun.dev/api/mcp --bearer-token-env-var METARUN_TOKENOr in config.toml
[mcp_servers.metarun]
url = "https://metarun.dev/api/mcp"
bearer_token_env_var = "METARUN_TOKEN"What Codex handles here
Apple has four offer types for subscriptions and they target different people: introductory offers for those who never subscribed, promotional offers for current subscribers, offer codes for anyone with a code, and win-back offers for people who left. Each has its own screens in App Store Connect and its own rules about price and eligibility.
MetaRun exposes each one as a preview and apply pair. Codex can create them, generate one-time codes, turn codes on and off, and read back what's live.
Before you start
- A subscription to attach the offer to.
- Who the offer is for: new, current, lapsed, or anyone with a code.
- Prices per storefront for paid offers; free trials only need territories.
How it runs
- 01
Match the offer to the audience
Codex picks the offer type from who it's for: never subscribed, subscribed now, lapsed, or anyone holding a code.
- 02
Price it per storefront
Paid offers take a price per territory. Free trials take a list of territories instead, because Apple wants no price on a free row.
- 03
Preview the offer
The preview shows the offer, its duration and where it applies, with a confirm token.
- 04
Generate and track codes
One-time codes are generated in a batch after the campaign exists. Campaigns can be switched off later without deleting them.
An example session in Codex
Add a 7-day free trial to com.example.app.pro.yearly for new subscribers in every storefront.
- apple_list_subscription_offersThe yearly plan has no introductory offer.
- apple_preview_create_intro_offerPreview: one-week free trial for new subscribers, every territory.
- Codex asks before running apple_apply_create_intro_offer. You read the preview above and approve.
- apple_apply_create_intro_offerCreated in every storefront.
- apple_preview_create_offer_codePreview: NEWSLETTER, 50% off for three months.
Illustrative: your apps, versions and numbers will differ. The tool names and their order are real.
The MetaRun tools Codex calls
| Tool | What it does |
|---|---|
| apple_list_subscription_offersread | Every offer on a subscription, across all four types. |
| apple_preview_create_intro_offerpreview + apply | Free trial, pay as you go, or pay up front for new subscribers. |
| apple_preview_create_promotional_offerpreview + apply | A discount current or lapsed subscribers can redeem in the app. |
| apple_preview_create_offer_codepreview + apply | An offer code campaign, with custom codes or one-time codes. |
| apple_preview_generate_offer_codespreview + apply | Mint a batch of one-time-use codes. |
| apple_preview_set_offer_code_activepreview + apply | Turn a code campaign on or off. |
| apple_preview_create_winback_offerpreview + apply | A win-back offer for people who cancelled (iOS 18 and later). |
| apple_preview_create_iap_offer_codepreview + apply | Offer codes for in-app purchases. |
Each preview has an apply twin (the same name with apply instead of preview) that only runs with the confirm token from a fresh preview, and refuses if App Store Connect changed in between. MetaRun tools save to your MetaRun workspace only (studio projects, tracked keywords), never to Apple.
What Apple enforces, and how MetaRun handles it
Intro offers are stored per territory
Apple keeps an introductory offer as one resource per storefront, so a 3-day trial in 175 storefronts is 175 records. MetaRun reads them back as one offer with a territory count.
Free trials carry no price
A free trial's price rows must have no price point. MetaRun takes territories instead of prices for free offers and refuses a mixed request at preview rather than repricing silently.
Issued codes can't be taken back
Generating codes isn't revertible, since a code already handed out can't be un-issued. Deactivating the campaign is the lever instead.
Win-back offers need iOS 18
Win-back offers reach people who subscribed before and cancelled, and only on iOS 18 and later.
What to ask Codex
- Ask Codex: Add a 7-day free trial to com.example.app.pro.yearly for new subscribers in every storefront.
- Ask Codex: Create an offer code campaign NEWSLETTER for 50% off the first 3 months, and generate 500 one-time codes.
- Ask Codex: Set up a win-back offer: 2 months at half price for people who cancelled in the last 6 months.
Run it from a script with Codex
codex exec runs one request without an interactive session and with its approval policy set to never. MetaRun's reads and previews still run, because they're marked read-only; anything that would ask is refused.
Read-only check, safe to schedule
codex exec "List every offer on each subscription of com.example.app: type, duration, territories and whether it is active. Read only."Applies are refused in codex exec by design. Don't set MetaRun's approval mode to approve just to make them pass; keep App Store changes in an interactive session.
How Codex asks before a change
Codex decides per tool from the hints MetaRun sends with each one. In its default mode it runs tools marked read-only, which covers MetaRun's reads and previews, and asks before the rest, which covers every apply. You can change that per server with default_tools_approval_mode, or per tool with tools.<name>.approval_mode in config.toml; keep the apply tools on prompt.
Frequently asked questions
Which offer type should I use?
Introductory offers for people who never subscribed, promotional offers for current subscribers, win-back offers for people who left, and offer codes when you hand out a code yourself. Codex can pick based on who you describe.
Can Codex generate one-time offer codes?
Yes. Create the campaign, then generate a batch of one-time-use codes. Generation isn't revertible, so it always previews first.
Can I offer a free trial in some countries only?
Yes. Free trials take a list of territories; leave it out for every storefront.
Do offers work for in-app purchases?
Offer codes do, through apple_preview_create_iap_offer_code. Introductory, promotional and win-back offers are subscription features in Apple's model.
How do I connect Codex to App Store Connect?
Run codex mcp add metarun --url https://metarun.dev/api/mcp; Codex detects MetaRun's sign-in and opens it in your browser. After that, ask for "offers and offer codes" in plain words and Codex picks the MetaRun tools.
Does Codex see my App Store Connect key?
No. Your App Store Connect API key stays envelope-encrypted on MetaRun's servers and is decrypted per request. Codex holds a MetaRun token that you can revoke in Settings at any time.
More with Codex
Codex
Subscriptions and IAPs
Create subscription groups, subscriptions and in-app purchases with copy and prices.
OpenCodex
Price by country
Reprice an app, IAP or subscription across 175 storefronts with PPP or Big Mac indexes.
OpenCodex
Reply to reviews
Triage App Store reviews, find the themes, and post replies you've approved.
OpenCodex
Submit for review
Attach the build, clear export compliance, run the readiness sweep, submit.
OpenOffers and offer codes with another agent
In depth: Bulk App Store pricing
Agent access
14-day free trial with agent access. No credit card. Your Apple key stays encrypted on MetaRun.