# Upload YouTube Shorts from Codex

Upload a hosted vertical demo as an unlisted YouTube Short. Have Codex confirm the upload through PubNio and return a link for review.

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

## 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 YouTube 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 YouTube channel in PubNio using Google OAuth and grant upload access.
- Choose the exact channel if several channels are available in the workspace.
- Export a square or vertical clip up to three minutes for Shorts classification.
- The clip at an HTTPS URL. A public or signed HTTPS link PubNio can fetch. A file of up to 8 MiB can go inline as base64 instead.

### Check the destination

```
List the YouTube channels in my PubNio workspace and show which are ready for uploads. Do not upload, schedule, or publish anything.
```

## Worked job: Upload an unlisted Short for team review

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

### Prompt

```
Find my ready YouTube channel in PubNio and ask which one to use if there are several. Import the clip at https://cdn.example.com/release-short.mp4 for an unlisted upload. Draft a short title and description from CHANGELOG.md. Show me the file, channel, title, description, and unlisted privacy setting before submitting. After I approve, wait for the clip to be ready and upload it once. Check the delivery and return the YouTube watch link, or the PubNio post ID and status if the upload is still pending.
```

### What Codex runs: the Code Mode flow

```text
search   -> find the media-import, media-status, create-post, and read-post operations
execute  -> import media { url: "https://cdn.example.com/release-short.mp4" }
         => 202 { mediaId: "…", status: "processing" }
execute  -> read media status, sleep 1s between checks
         => { status: "ready" }
execute  -> create post { text: "…", publishNow: true, targets: [ { accountId: "…", provider: "youtube", placement: "video", settings: { title: "Delivery status in 45 seconds", description: "A quick tour of the new delivery status view.", privacyStatus: "unlisted" }, media: [ { mediaId: "…" } ] } ] }
            Idempotency-Key: codex-youtube-release-short-2026-12-04
         => 202 { postId, targets: [youtube/video: queued] }
execute  -> read post, sleep 1s between checks, within the 30s budget
         => { status: "published", url: "https://www.youtube.com/watch?v=EXAMPLE0000" }
```

### Settled result (200 OK)

```json
{
  "postId": "00000000-0000-4000-8000-000000000002",
  "isDraft": false,
  "revision": 1,
  "scheduledAt": null,
  "text": "A quick tour of the new delivery status view.",
  "media": [
    {
      "mediaId": "00000000-0000-4000-8000-000000000005"
    }
  ],
  "targets": [
    {
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "youtube",
      "placement": "video",
      "settings": {
        "title": "Delivery status in 45 seconds",
        "description": "A quick tour of the new delivery status view.",
        "privacyStatus": "unlisted"
      },
      "media": [
        {
          "mediaId": "00000000-0000-4000-8000-000000000005"
        }
      ]
    }
  ],
  "deliveries": [
    {
      "targetId": "00000000-0000-4000-8000-000000000003",
      "attemptId": "00000000-0000-4000-8000-000000000004",
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "youtube",
      "placement": "video",
      "canRetry": false,
      "canReconcile": false,
      "revision": 1,
      "status": "published",
      "providerRef": {
        "id": "EXAMPLE0000",
        "kind": "video"
      },
      "url": "https://www.youtube.com/watch?v=EXAMPLE0000"
    }
  ],
  "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’ll upload release-short.mp4 to the Example Studio channel as unlisted. The title is “Delivery status in 45 seconds.” The description is “A quick tour of the new delivery status view.”

**You:** Approved. Keep it unlisted so the team can review it.

**Codex:** The clip finished importing. I submitted one upload and checked the existing post until YouTube confirmed delivery. Here’s the watch link. Check its visibility and Shorts classification in YouTube Studio before sharing it.

#### Example delivery result

- Status: `published`

- Destination: Example Studio · Unlisted requested

- Sample URL: `https://www.youtube.com/watch?v=EXAMPLE0000`

## Check delivery and get the link

- Save the PubNio post ID after the upload is accepted.
- Check the delivery on that post while the upload is queued, submitting, or confirming.
- When the delivery is published, return the YouTube watch URL and keep the video unlisted for review.
- Check in YouTube Studio that the upload is unlisted and classified as a Short before sharing the link.

## YouTube rules Codex runs into

Account kinds: social channel. Connection scopes: `https://www.googleapis.com/auth/youtube.upload`.

| Placement | Default | Media types | Max per target | Caption limit |
| --- | --- | --- | --- | --- |
| `video` | Yes | video | 1 | 5,000 |

- The video placement takes one video.
- Export a square or vertical clip of up to three minutes for Shorts classification. YouTube decides whether the upload is a Short.
- Keep the description within 5,000 characters, and set privacy to public, unlisted, or private.
- Use unlisted for link-based review. Anyone with the link can view an unlisted video.

## Failures and recovery

### YouTube 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 |
| `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_type` | Media kind (image, video, document) does not match the placement. | Supply a matching media type for the selected placement. | No |
| `media_not_ready` | Media import or verification is still in progress. | Poll `media.status` until it reports `ready`, then re-validate. | Yes |

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

- Decide whether an upload becomes a Short. YouTube classifies it after upload.
- Upload an image or text post to YouTube. The video placement takes one video.
- Raise YouTube's daily API quota or a channel's upload limit.
- 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

### Is there a separate Shorts upload operation?

Use the video placement. YouTube classifies eligible square and vertical videos as Shorts after upload.

### Can Codex upload an unlisted Short?

Set the YouTube target privacy to unlisted and confirm the resulting visibility in YouTube Studio.

### Does a PubNio 202 response mean the Short is ready?

A 202 means PubNio accepted the upload. Read the existing post to check whether YouTube confirmed delivery.

### Which link should I share for review?

Use the watch URL from the confirmed YouTube delivery after checking the video's privacy in YouTube Studio.

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

- [Upload YouTube Shorts from Claude Code](https://pubnio.com/claude/youtube)
- [Upload YouTube Shorts from Cursor](https://pubnio.com/cursor/youtube)
- [Upload YouTube Shorts from OpenCode](https://pubnio.com/opencode/youtube)
- [Post to Instagram from Codex](https://pubnio.com/codex/instagram)
- [Post to LinkedIn from Codex](https://pubnio.com/codex/linkedin)
- [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)
- [Publish an X thread from Codex](https://pubnio.com/codex/x)
- [Codex setup](https://pubnio.com/codex)
- [YouTube publishing API](https://pubnio.com/platforms/youtube)
- [YouTube MCP](https://pubnio.com/youtube-mcp)
- [YouTube network reference](https://pubnio.com/docs/networks/youtube/)
- [YouTube error codes](https://pubnio.com/docs/errors/youtube/)
- [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-youtube-release-short-2026-12-04
Content-Type: application/json

{
  "text": "A quick tour of the new delivery status view.",
  "publishNow": true,
  "targets": [
    {
      "accountId": "00000000-0000-4000-8000-000000000001",
      "provider": "youtube",
      "placement": "video",
      "settings": {
        "title": "Delivery status in 45 seconds",
        "description": "A quick tour of the new delivery status view.",
        "privacyStatus": "unlisted"
      },
      "media": [
        {
          "mediaId": "00000000-0000-4000-8000-000000000005"
        }
      ]
    }
  ]
}
```

### 202 Accepted

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

