OpenAI Codex and Instagram: an integration in five minutes
Last reviewed:
Codex can call MCP servers. Add DMowl to ~/.codex/config.toml as [mcp_servers.dmowl] with url = "https://dmowl.com/mcp", then run codex mcp login dmowl and click Allow. Codex can then read and change your Instagram automations, contacts and campaigns while it writes code for you.
Why connect Codex to Instagram?
Codex is OpenAI’s coding agent. Connected to DMowl it works with live data from your Instagram account instead of guessing, which helps whenever your code and your DMs meet:
- Build a landing page and the comment-to-DM automation that sends people to it, in one session.
- Write a script that pushes new Instagram leads (with email) into your CRM or database.
- Wire Shopify or Stripe orders back to the DM that caused them, using DMowl’s conversion tracking.
- Generate test data and check your webhook endpoint with real event shapes.
Setup with OAuth (recommended)
- 1 Connect Instagram to DMowl
Create a DMowl account and connect your Instagram professional account.
- 2 Add the server
Open ~/.codex/config.toml (or .codex/config.toml in a trusted project) and add: [mcp_servers.dmowl] and on the next line url = "https://dmowl.com/mcp".
- 3 Log in
Run codex mcp login dmowl. Your browser opens the DMowl Allow page; sign in and confirm.
- 4 Try it
Start Codex and ask: “Use DMowl to list my active automations and their click rates.”
Setup with an API key (CI and servers)
Where no browser is available, create an API key in DMowl under Settings → API & MCP and keep it in an environment variable, for example DMOWL_API_KEY. In config.toml add bearer_token_env_var = "DMOWL_API_KEY" below the url. Codex sends it as Authorization: Bearer.
Never commit the key. Codex reads it from the environment, so the config file itself stays safe to share.
Codex or the REST API?
| Use | When |
|---|---|
| Codex + MCP | While building: exploring data, creating automations, trying things out |
| REST API | In production code: scheduled jobs, your backend, webhooks. Same features at dmowl.com/api/v1 |
| Webhooks | When DMowl should notify your system: new email, link click, giveaway entry, opt-out, order |
Questions? Answers.
Does Codex get access to my Instagram password?
No. Instagram is connected to DMowl through Meta’s login. Codex gets a revocable DMowl token or uses your API key.
Can I use the same setup in ChatGPT?
Yes, ChatGPT uses the same server URL. See our guide on managing Instagram DMs with ChatGPT.
What if codex mcp login is not available?
Update Codex to a current version, or use the API key setup with bearer_token_env_var, which works without a browser.
Free tools for this
Try it on your own Instagram
Free for up to 100 active contacts. No credit card, set up in two minutes.
Start for freeMore guides
- 💬 How to send an automatic DM when someone comments on Instagram
- ⏱️ Instagram’s 24-hour messaging window, explained
- 🍀 How to pick an Instagram giveaway winner fairly
- 💬 How to manage your Instagram DMs with ChatGPT
- 🧠 How to connect Claude to your Instagram account
- 🔌 The Instagram MCP server: connect AI agents to your DMs
- ✍️ 25 prompts to run your Instagram DMs with ChatGPT or Claude
- 🛠️ Connect Cursor, VS Code, Gemini CLI and Claude Code to Instagram
- 🤖 Can ChatGPT answer your Instagram DMs automatically?
- 🔎 Analyse your Instagram DMs with AI
- 📥 How to get your Instagram messages into ChatGPT or Claude
- 🔁 Instagram DM automation with AI in n8n, Make and Zapier
Looking for how a DMowl feature works? DMowl documentation →