# Publish an X thread from Codex

Turn a changelog into a short thread. Approve the text, account, and estimated X API fees, then check the published thread link.

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

## 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 X account

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

- Connect the X account you want to post from in PubNio and confirm it is ready.
- Open the repository containing your changelog in Codex.
- Review the current X pass-through estimate in PubNio before approving.
- Make sure your workspace has enough prepaid credit for the estimated X fees.

### Check the destination

```
List the X accounts in my PubNio workspace and show which are ready to publish. Do not create, schedule, or publish posts.
```

## Worked job: Turn your changelog into an X thread

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

### Prompt

```
Read CHANGELOG.md and draft a short X thread with an opener and two replies. Keep each post within 280 characters. Show the destination account and every post. Validate the thread with PubNio to get the publishing fee estimate, including X pass-through fees, and wait for my approval. If validation is blocked or the cost is unavailable, stop. After approval, publish once, then read the delivery and return the thread’s opening-post link.
```

### What Codex runs: the Code Mode flow

```text
search   -> find the validate-post, create-post, and read-post operations
execute  -> validate post { text: "…", publishNow: true, targets: [ { accountId: "…", provider: "x", placement: "feed", settings: { thread: [ "Set a recurring schedule once for each account.", "Add a post to the queue and check delivery when it goes live." ] } } ] }
         => { canPublish: true, billing: { xPublishes: 3, estimatedCost: "…", blocked: null } }
            show the estimate and wait for approval
execute  -> create post { text: "…", publishNow: true, targets: [ { accountId: "…", provider: "x", placement: "feed", settings: { thread: [ "Set a recurring schedule once for each account.", "Add a post to the queue and check delivery when it goes live." ] } } ] }
            Idempotency-Key: codex-x-weekly-queues-thread
         => 202 { postId, targets: [x/feed: queued] }
execute  -> read post, sleep 1s between checks, within the 30s budget
         => { status: "published", url: "https://x.com/i/web/status/1234567890" }
```

### Settled result (200 OK)

```json
{
  "postId": "00000000-0000-4000-8000-000000000002",
  "isDraft": false,
  "revision": 1,
  "scheduledAt": null,
  "text": "Weekly queues are here. Here’s what changed.",
  "media": [],
  "targets": [
    {
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "x",
      "placement": "feed",
      "settings": {
        "thread": [
          "Set a recurring schedule once for each account.",
          "Add a post to the queue and check delivery when it goes live."
        ]
      }
    }
  ],
  "deliveries": [
    {
      "targetId": "00000000-0000-4000-8000-000000000003",
      "attemptId": "00000000-0000-4000-8000-000000000004",
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "x",
      "placement": "feed",
      "canRetry": false,
      "canReconcile": false,
      "revision": 1,
      "status": "published",
      "providerRef": {
        "id": "1234567890",
        "kind": "post"
      },
      "url": "https://x.com/i/web/status/1234567890"
    }
  ],
  "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’ve drafted an opener and two replies for @example. Here are all three posts and the PubNio estimate, including the X API fee for each write.

**You:** I’ve reviewed the thread, destination, and estimated fees. Publish it once.

**Codex:** PubNio accepted the thread. I checked the original delivery and got the confirmed link to the opening post.

#### Example delivery result

- Status: `published`

- Destination: @example · three-post X thread

- Sample URL: `https://x.com/i/web/status/1234567890`

## Check delivery and get the link

- Review the validation estimate before any publish request.
- Save the PubNio post ID after admission.
- Check the existing delivery until it confirms and returns the opening-post URL.
- Open the thread to check the replies. If submission is unresolved, reconcile the existing target before trying again.

## X rules Codex runs into

Account kinds: social account. Connection scopes: `tweet.write`.

| Placement | Default | Media types | Max per target | Caption limit |
| --- | --- | --- | --- | --- |
| `feed` | Yes | image, video | 4 | 280 |

- This walkthrough uses a text-only feed target.
- A feed post takes up to 4 images or videos.
- Put the opening text in the post body and the replies in the target’s thread settings.
- Keep each post to 280 characters.
- If you add URLs, review the new estimate. X charges can vary with the content of each write.

## Failures and recovery

### X 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 |
| `empty_content` | Neither text nor media was provided for a target that requires content. | Add caption text or attach a ready media ID. | No |
| `caption_too_long` | Text exceeds the destination placement's character limit (`caption.limit`). | Shorten the caption or add a shorter target-specific text override. | No |
| `insufficient_credit` (billing, 402) | Prepaid credit cannot cover the publish, including X pass-through fees. | Top up credit or upgrade the plan. | After a top-up |
| `spend_cap_reached` (billing, 402) | The publish would pass the workspace's monthly spend cap. | Raise the monthly spend cap in billing settings. | After raising the cap |

### 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

- Waive X API fees ($0.015 a post, or $0.20 with a link). They pass through on every plan.
- Publish when prepaid credit cannot cover the estimated X fees.
- Post identical copy again. X rejects duplicates, so check the existing delivery first.
- 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 turn release notes into an X thread?

Yes. Use the X feed placement with opening text and ordered replies, then approve the prepared thread.

### What does it cost to publish an X thread?

Validate the thread for PubNio’s current estimate. X API create fees are separate, and a thread contains multiple writes.

### Which link does PubNio return?

The confirmed X delivery links to the opening post. Open that link to review the thread.

### Should I resubmit if Codex stops waiting?

Save the PubNio post ID and recheck the same delivery. If the outcome is unresolved, reconcile before retrying.

### 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

- [Publish an X thread from Claude Code](https://pubnio.com/claude/x)
- [Publish an X thread from Cursor](https://pubnio.com/cursor/x)
- [Publish an X thread from OpenCode](https://pubnio.com/opencode/x)
- [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)
- [Post to a Facebook Page from Codex](https://pubnio.com/codex/facebook)
- [Create a Pinterest Pin from Codex](https://pubnio.com/codex/pinterest)
- [Post a TikTok video from Codex](https://pubnio.com/codex/tiktok)
- [Codex setup](https://pubnio.com/codex)
- [X publishing API](https://pubnio.com/platforms/x)
- [X MCP](https://pubnio.com/x-mcp)
- [X network reference](https://pubnio.com/docs/networks/x/)
- [X error codes](https://pubnio.com/docs/errors/x/)
- [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-x-weekly-queues-thread
Content-Type: application/json

{
  "text": "Weekly queues are here. Here’s what changed.",
  "publishNow": true,
  "targets": [
    {
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "x",
      "placement": "feed",
      "settings": {
        "thread": [
          "Set a recurring schedule once for each account.",
          "Add a post to the queue and check delivery when it goes live."
        ]
      }
    }
  ]
}
```

### 202 Accepted

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

