# Post to a Facebook Page from Codex

Give Codex your release notes and the name of the Facebook Page. Review the text, approve it once, and check the Page post through PubNio.

Canonical page: https://pubnio.com/codex/facebook

## Connect Codex

### Add PubNio to .codex/config.toml

codex mcp add writes this entry to ~/.codex/config.toml for your user. To share the server with the repository, put the same entry in the project's .codex/config.toml.

```toml
[mcp_servers.pubnio]
url = "https://pubnio.com/mcp"
```

Or from a terminal:

```sh
codex mcp add pubnio --url https://pubnio.com/mcp
codex mcp login pubnio
```

### Sign in

1. Run codex mcp login pubnio in a terminal.
2. Your browser opens PubNio sign-in; approve the workspace.
3. Start Codex in the repository and ask it to list your PubNio workspaces.

### Install the skill (optional)

```sh
npx skills add pubnio/agent-skills
```

Installs the pnio skill from skills.sh.

### Connect your Facebook account

[Open PubNio](https://pubnio.com/app), choose your workspace, and go to Accounts. Use the same workspace when you sign in from Codex.

- Choose a Facebook Page you can manage.
- Connect the Page in PubNio through Meta OAuth and grant Page publishing access.
- Check that PubNio lists the Page as ready before asking Codex to publish.
- Open the repository with your changelog in Codex.

### Check the destination

```
List the Facebook Pages in my PubNio workspace. Show their names and which ones are ready to publish. Do not create, schedule, or publish a post.
```

## Worked job: Post a release announcement to a Facebook Page

Contract example: sample IDs and URLs. The request and both responses decode against PubNio's API schemas; no provider confirmed this post.

### Prompt

```
Read the latest entry in CHANGELOG.md and draft a short Facebook Page update for customers. Find my ready Pages in PubNio and ask me if the destination is ambiguous. Show me the Page and exact text. After I approve, publish one text-only feed post. Check the existing delivery and return the Facebook permalink, or the PubNio post ID if it is still pending.
```

### What Codex runs: the Code Mode flow

```text
search   -> find the create-post and read-post operations
execute  -> create post { text: "…", publishNow: true, targets: [ { accountId: "…", provider: "facebook", placement: "feed" } ] }
            Idempotency-Key: codex-facebook-release-2026-12-04
         => 202 { postId, targets: [facebook/feed: queued] }
execute  -> read post, sleep 1s between checks, within the 30s budget
         => { status: "published", url: "https://www.facebook.com/101/posts/77" }
```

### Settled result (200 OK)

```json
{
  "postId": "00000000-0000-4000-8000-000000000002",
  "isDraft": false,
  "revision": 1,
  "scheduledAt": null,
  "text": "Weekly queues are here. Pick a posting schedule once, then add releases to the next available slot.",
  "media": [],
  "targets": [
    {
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "facebook",
      "placement": "feed"
    }
  ],
  "deliveries": [
    {
      "targetId": "00000000-0000-4000-8000-000000000003",
      "attemptId": "00000000-0000-4000-8000-000000000004",
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "facebook",
      "placement": "feed",
      "canRetry": false,
      "canReconcile": false,
      "revision": 1,
      "status": "published",
      "providerRef": {
        "id": "101_77",
        "kind": "post"
      },
      "url": "https://www.facebook.com/101/posts/77"
    }
  ],
  "status": "published",
  "createdAt": "2026-12-04T07:20:00.000Z",
  "updatedAt": "2026-12-04T07:20:18.000Z"
}
```

### From approval to delivery

Illustrative conversation and result with sample data.

**Codex:** I found two ready Facebook Pages. For Example Studio, the proposed feed post is “Weekly queues are here. Pick a posting schedule once, then add releases to the next available slot.”

**You:** Use the Example Studio Page. The text is approved.

**Codex:** PubNio accepted one feed post. I checked that post again and got a confirmed Facebook permalink.

#### Example delivery result

- Status: `published`

- Destination: Example Studio · Facebook Page feed

- Sample URL: `https://www.facebook.com/101/posts/77`

## Check delivery and get the link

- Save the post ID after PubNio accepts the request.
- Check that the delivery is for the same Facebook Page you approved.
- Read the same delivery until it is published and returns its Page permalink.
- If the result is unresolved, inspect the Page before retrying the existing target.

## Facebook rules Codex runs into

Account kinds: social page. Connection scopes: `pages_manage_posts`, `pages_read_engagement`, `pages_show_list`.

| Placement | Default | Media types | Max per target | Caption limit |
| --- | --- | --- | --- | --- |
| `feed` | Yes | image, video | 10 | 63,206 |
| `reel` | — | image, video | 10 | 63,206 |
| `story` | — | image, video | 10 | 63,206 |

- A Page feed update can be text-only.
- A feed post takes up to 10 images or videos.
- A Reel takes up to 10 images or videos.
- A Story takes up to 10 images or videos.
- Use the Reel or Story placement when you want that native format.
- Stage attachments before publishing. Use an H.264 MP4 with AAC audio for video.

## Failures and recovery

### Facebook issue codes

| Code | Cause | Fix | Retry |
| --- | --- | --- | --- |
| `account_not_ready` | The connected account's OAuth token is expired, revoked, or disconnected. | Reconnect the account in the PubNio workspace, then re-validate. | After reconnect |
| `publish_permission_required` | The OAuth grant is missing a required publishing scope. | Re-authorize the account in the workspace with publish permissions enabled. | After reconnect |
| `media_required` | Placement (such as Instagram Feed/Reel, Pinterest Pin, TikTok, or YouTube) requires media. | Import or upload media and attach its `mediaId` to the target. | No |
| `media_mime_type` | File MIME type is rejected by the provider (for example, unsupported codec or container). | Convert to a supported MIME type (such as `image/jpeg`, `image/png`, `video/mp4`, or `application/pdf`). | No |

### Codex setup problems

- Calls start failing with 401. Run codex mcp login pubnio again to renew the PubNio sign-in.
- Codex does not show the pubnio tools. Run codex mcp add pubnio --url https://pubnio.com/mcp again, or check that [mcp_servers.pubnio] is in config.toml.
- Writes fail with 403 read_only_mode. PubNio returns 403 read_only_mode when the server URL ends in ?readOnly=1. Point the entry at https://pubnio.com/mcp to allow writes.

### Codex quirks

- Sign-in runs from the terminal with codex mcp login pubnio, outside a Codex session.
- The TOML entry needs only url; the table name [mcp_servers.pubnio] is the server name.

## What it won't do

- Publish to a personal Facebook profile. PubNio connects Pages only.
- Publish a Reel or Story without media.
- Connect accounts, create API keys, or manage webhooks from an MCP session that uses an API key. Those operations need a person signed in, so connect the MCP server with browser OAuth or use the PubNio web app.
- Stream binary uploads through execute. Import media from an HTTPS URL, or send a file of up to 8 MiB inline as base64.
- Run one execute call past 30 seconds or past its request limit. The script returns the post ID so the next call can check it.

## Frequently asked questions

### Can Codex publish to my personal Facebook profile?

This guide publishes to a connected Facebook Page. Select the Page you have permission to manage.

### Can I post an update without an image?

Yes. Use a text-only feed post on the selected Page.

### How do I avoid posting to the wrong Page?

Ask Codex to list the ready Pages, then approve the Page name alongside the text.

### Does accepted mean the Page post is public?

Accepted means PubNio queued the delivery. Check the same post for a confirmed Facebook permalink.

### Where does Codex keep the PubNio server?

In config.toml under [mcp_servers.pubnio] with url = "https://pubnio.com/mcp". codex mcp add writes it to ~/.codex/config.toml; a project can keep the same entry in .codex/config.toml.

### How do I sign Codex in again?

Run codex mcp login pubnio. Each client keeps its own PubNio sign-in.

## Also works with

- [Post to a Facebook Page from Claude Code](https://pubnio.com/claude/facebook)
- [Post to a Facebook Page from Cursor](https://pubnio.com/cursor/facebook)
- [Post to a Facebook Page from OpenCode](https://pubnio.com/opencode/facebook)
- [Post to Instagram from Codex](https://pubnio.com/codex/instagram)
- [Post to LinkedIn from Codex](https://pubnio.com/codex/linkedin)
- [Upload YouTube Shorts from Codex](https://pubnio.com/codex/youtube)
- [Create a Pinterest Pin from Codex](https://pubnio.com/codex/pinterest)
- [Post a TikTok video from Codex](https://pubnio.com/codex/tiktok)
- [Publish an X thread from Codex](https://pubnio.com/codex/x)
- [Codex setup](https://pubnio.com/codex)
- [Facebook publishing API](https://pubnio.com/platforms/facebook)
- [Facebook MCP](https://pubnio.com/facebook-mcp)
- [Facebook network reference](https://pubnio.com/docs/networks/facebook/)
- [Facebook error codes](https://pubnio.com/docs/errors/facebook/)
- [Pricing](https://pubnio.com/pricing)

## Get started with PubNio

Connect unlimited accounts at $0 per account. Pay as you go includes 50 free confirmed publishes a month on your first workspace, then $20 per 1,000. X API fees are separate.

## REST API reference

Contract example: sample IDs and URLs. The request and both responses decode against PubNio's API schemas; no provider confirmed this post.

```http
POST /api/v1/posts?workspaceId=00000000-0000-4000-8000-000000000006
Authorization: Bearer pn_live_***
Idempotency-Key: codex-facebook-release-2026-12-04
Content-Type: application/json

{
  "text": "Weekly queues are here. Pick a posting schedule once, then add releases to the next available slot.",
  "publishNow": true,
  "targets": [
    {
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "facebook",
      "placement": "feed"
    }
  ]
}
```

### 202 Accepted

```json
{
  "postId": "00000000-0000-4000-8000-000000000002",
  "idempotencyKey": "codex-facebook-release-2026-12-04",
  "targets": [
    {
      "targetId": "00000000-0000-4000-8000-000000000003",
      "attemptId": "00000000-0000-4000-8000-000000000004",
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "facebook",
      "placement": "feed",
      "canRetry": false,
      "canReconcile": false,
      "status": "queued",
      "scheduledAt": null,
      "url": null,
      "issue": null
    }
  ],
  "warnings": []
}
```

