# How to connect Instagram to OpenAI Codex

> Add Saypage to Codex with an API key, once for the CLI, the IDE extension and the app: Instagram insights, comments, posts and pages.

Source: https://saypage.ai/integrations/codex · Updated December 2, 2026

Codex can't reach Instagram by itself. Saypage is an MCP server that gives it Instagram tools, through the official Instagram API: your insights, your comments, posting, Reels, your pages on `yourname.saypage.page` and your comment-to-DM automations. You add it once with an API key, and the Codex CLI, the IDE extension and the app all share it, since they read the same configuration.

## What you need

- **Codex**: the CLI, the IDE extension or the app.
- **An Instagram professional account**, Business or Creator, connected to Saypage.
- **A Saypage account and an API key.** [Create your account](https://saypage.ai/sign-up), connect Instagram, then create a key on your account's [API keys](https://saypage.ai/account/api-keys) page.

## Step 1: create an API key

On your Saypage account, open **API keys** and create one:

- **Read only** for questions and reports: insights, posts, comments, pages and their statistics. It can't post, reply or send anything.
- **Full access** to let Codex publish pages, reply to comments and post, always after you approve it in the conversation.

Copy the key (it starts with `sp_`): Saypage shows it once. More in [Saypage API keys](https://saypage.ai/docs/api-keys).

## Step 2: put the key in your environment

Codex reads the key from an environment variable, so it never sits in a configuration file. Add this line to your shell profile (`~/.zshrc` or `~/.bashrc`), with your key:

```bash
export SAYPAGE_API_KEY="sp_…"
```

Open a new terminal, or run `source ~/.zshrc`, so the variable exists.

## Step 3: add Saypage to Codex

```bash
codex mcp add saypage --url https://api.saypage.ai/mcp --bearer-token-env-var SAYPAGE_API_KEY
```

This writes the server in `~/.codex/config.toml`:

```toml
[mcp_servers.saypage]
url = "https://api.saypage.ai/mcp"
bearer_token_env_var = "SAYPAGE_API_KEY"
```

You can also write those three lines by hand. Run `codex mcp list` to check: **saypage** shows with **Bearer token** as its auth.

## Step 4: check that it works

Start Codex and ask: **"Get started with Saypage."** It answers with a short welcome and what it can do with your account. Then try:

- "Which of my last 20 Instagram posts did best, and why?"
- "Build a link-in-bio page for me in this folder, then show me a Saypage preview."

If Codex says it has no Saypage tools, check that `SAYPAGE_API_KEY` is set in the environment Codex starts from.

## Why not sign in instead of a key?

Saypage's sign-in registers apps with a client ID metadata document, as the latest MCP specification recommends, and doesn't offer the older dynamic client registration. In our test on December 2, 2026, `codex mcp login` (Codex CLI 0.141) only tried dynamic registration and stopped with "Dynamic client registration not supported". An API key works in every version, and you choose exactly what it may do.

## What Codex does well with Saypage

- **Pages from your project.** Codex writes the HTML in your repository and sends it to Saypage as a file; you get a private preview, then publish it on your address when you're happy.
- **Reports and scripts.** In `codex exec`, Codex runs without a chat: a scheduled job can ask for yesterday's Instagram numbers with a read-only key.
- **Bulk checks.** "List my automations and tell me which ones sent no DM this week", or "which pages got no visit from Instagram this month".

## What Codex can do with your Instagram

What it can do depends on your Saypage plan, and on the key: a read-only key only reads, on any plan.

| Ask Codex to… | Saypage plan |
|---|---|
| Read your posts, Reels and insights, and say what to post next | Free and every plan |
| Find the comments you haven't answered, draft replies, hide spam | Creator ($19 a month) and Premium |
| Publish photo posts, carousels, Reels and stories, once you turn publishing on | Creator and Premium |
| Build pages and put them online on your address | Creator and Premium |
| Send a link by DM to everyone who comments a keyword | Creator and Premium |

Each paid plan starts with a 7-day free trial. The full list of tools is in the [MCP tools reference](https://saypage.ai/docs/tools).

## What it can't do

Saypage only does what the official Instagram API allows. Codex can't read or answer your DM inbox, message your followers in bulk, change your bio, delete a published post, or act on someone else's account.

## Questions

### Does Codex have an Instagram integration?

Not one of its own. Codex reaches other services through MCP servers, and Saypage is one built for Instagram creators, on the official Instagram API.

### Is it free?

Adding Saypage is free, and on Saypage's Free plan Codex reads your posts and insights. Comments, posting, pages and DM automations start with Creator, at $19 a month, with 7 days free. See [Plans and limits](https://saypage.ai/docs/plans).

### Does it work in the Codex IDE extension and app?

They read the same configuration as the CLI, so Saypage is there once `config.toml` has it. Start them from an environment where `SAYPAGE_API_KEY` is set.

### Can I use a different key per project?

Yes: a trusted project can have its own `.codex/config.toml`, pointing at another environment variable. Each key belongs to one Saypage account.

### What if my key leaks?

Revoke it on your account's API keys page: it stops working at once. Then create a new one and update the variable. See [Saypage API keys](https://saypage.ai/docs/api-keys).

### Is it safe for my Instagram account?

Saypage connects to Instagram through its official login and passed Meta App Review for every permission it uses. It never sees your Instagram password and never reads your DMs. See [Privacy and safety](https://saypage.ai/docs/privacy-and-safety).

## Next

- [How to connect Instagram to Claude Code](https://saypage.ai/integrations/claude-code)
- [How to connect Instagram to Cursor and Grok Build](https://saypage.ai/integrations/cursor)
- [Instagram MCP server](https://saypage.ai/integrations/instagram-mcp-server)
