Testing Post-Purchase Subject Lines with OpenAI Codex
Post-purchase emails are some of your highest-engagement sends — but the subject line still decides who opens. This guide shows how to run a subject line test for post-purchase campaigns directly from OpenAI Codex using marginal, a hosted email MCP server built for AI agents.
Why test post-purchase subject lines
The window right after a purchase is full of intent. Order confirmations, shipping updates, and thank-you sequences see strong opens, which makes them ideal candidates for a subject line A/B test — small wording changes here compound across every order.
Common levers worth testing in post-purchase flows include order-number visibility, delivery-time framing, gratitude versus utility, and personalization with the product name. A disciplined subject line test removes the guesswork.
- "Your order is on the way" vs "Order #1284 ships today"
- Gratitude-first vs status-first framing
- Including the purchased product name in the line
- Emoji vs plain text for confirmation emails
Connecting OpenAI Codex to marginal
marginal exposes four MCP tools — generate_variants, launch_test, get_results, and recommend_next — over a hosted endpoint at https://marginal.sh/mcp. Because it is fully hosted, there's no server to deploy and no ESP API keys to wire up; you authenticate with a Bearer API key (marg_live_...).
Once the server is registered in OpenAI Codex, you can drive the entire post-purchase experiment in plain language without leaving your workflow. See https://marginal.sh/mcp and the docs at https://marginal.sh/docs/ for the latest tool reference.
- Endpoint: https://marginal.sh/mcp
- Auth: Bearer API key (marg_live_...)
- Free tier: 100 experiments/month
- No self-hosting and no Mailchimp/Klaviyo keys required
Running the post-purchase subject line test
A typical post-purchase workflow in OpenAI Codex moves through generation, launch, and measurement. Ask Codex to draft variants tuned to your order-confirmation tone, then launch a managed send and let marginal handle open and click tracking automatically.
When results stabilize, get_results reports within-test lift so you can see which subject line actually moved opens, and recommend_next suggests the follow-up variant to try.
- Call generate_variants for 4–6 post-purchase subject candidates
- Use launch_test to split traffic and trigger managed sends
- Track opens and clicks with built-in measurement
- Read within-test lift via get_results before declaring a winner
- Iterate with recommend_next for the following order cycle
Making AI agent email marketing repeatable
Because the loop lives inside OpenAI Codex, post-purchase subject line testing becomes a repeatable step rather than a one-off task. The same prompts and tool calls can be reused across product lines, seasonal campaigns, and confirmation versus thank-you sequences.
This is the practical shape of AI agent email marketing: the agent proposes, marginal tests and measures, and you keep the variants that earn higher opens — all backed by real lift metrics instead of intuition.
- Reuse the workflow across every post-purchase email type
- Let data from each subline test inform the next round
- Keep generation and analysis in one editor-native loop
Get started with marginal
marginal is a hosted email marketing MCP server at marginal.sh. Sign up free, create an API key, and connect https://marginal.sh/mcp from Cursor, Codex, or Claude Desktop.
- 100 experiments/month on the free tier
- Four MCP tools: generate_variants, launch_test, get_results, recommend_next
- Listed in the MCP Registry as sh.marginal/mcp