Skip to content

Post to social media from Codex

Add Postkey to Codex and hand it the posting chores: publish, schedule, retry what failed and tell you when an account needs reconnecting.

No card required.

Codex

~/.codex/config.toml

[mcp_servers.postkey]
command = "npx"
args = ["-y", "mcp-remote", "https://mcp.postkey.dev", "--header", "x-access-key:${POSTKEY_API_KEY}"]
env = { POSTKEY_API_KEY = "pk_live_…" }

Works in the Codex CLI and the IDE extension, which share this file.

A real session

You ask in plain words. The agent picks the Postkey tools, and your client asks you before each call. The result shows every network's outcome and the credits it used.

Try this prompt

Retry yesterday's failed posts. If one can't be retried, tell me why.

codex · ~/studio-north

› Retry yesterday's failed posts. If one can't be retried, tell me why.

• Called postkey.list_posts({"status":"failed","from":"2026-11-24"})

post_7Tq2c Instagram: The video was still processing. · post_9Lw4e TikTok: The account's login expired. Reconnect it.

• Called postkey.retry_post({"postId":"post_7Tq2c"})

published · instagram.com/p/DC9xK… · 1 credit

• Called postkey.get_connect_link({"platform":"tiktok"})

https://www.tiktok.com/v2/auth/authorize?client_key=…

• The Instagram post is live now (1 credit). The TikTok one failed because the account's login expired, so a retry would fail again. Reconnect TikTok with the link above, then ask me to retry post_9Lw4e.

What Codex can do with Postkey

Each tool calls one Postkey endpoint and costs the same credits as calling it yourself. Failed networks are refunded.

What Codex can do with Postkey: endpoints and credit costs
ToolWhat it doesEndpointCredits
list_accountsThe connected accounts the agent can post to, with their idsGET /v1/connect/integrations0
create_postPublish now, schedule for a time and time zone, or save a draftPOST /v1/posts1 per network · X 5, or 50 with a link · draft 0
get_postOne post with the result and live URL for each networkGET /v1/posts/{postId}0
list_postsRecent posts, filtered by status, network or dateGET /v1/posts0
list_scheduled_postsEverything queued, soonest firstGET /v1/posts/scheduled0
reschedule_postMove a scheduled post to a new timePATCH /v1/posts/scheduled/{postId}0
cancel_scheduled_postCancel it. It goes back to draftDELETE /v1/posts/scheduled/{postId}Refunds its credits
retry_postSend only the networks that failed againPOST /v1/posts/{postId}/retrySame as posting, refunded if it fails again
upload_mediaUpload an image or video and get a URL to post withPOST /v1/media/upload0
get_connect_linkA sign-in link to connect a new accountGET /v1/connect/{platform}0
get_usageCredits used and left this monthGET /v1/usage0

Set up Codex in four steps

Copy each step as it is. Replace the key with yours.

  1. Get your key

    Reserve a free key. The same key works for the REST API and the MCP server, and you can make one key per agent so you can revoke it alone.

    export POSTKEY_API_KEY=pk_live_…
    # put it in your shell profile or .env, never in a repo
  2. Add Postkey to config.toml

    Paste the block into ~/.codex/config.toml. The Codex CLI and the IDE extension both read it. mcp-remote passes your key to the hosted server.

    [mcp_servers.postkey]
    command = "npx"
    args = ["-y", "mcp-remote", "https://mcp.postkey.dev", "--header", "x-access-key:${POSTKEY_API_KEY}"]
    # start codex again, then run /mcp to see postkey
  3. Connect an account

    Connect X, LinkedIn or any other network once in the dashboard. Or ask the agent for a sign-in link and open it.

    › Give me a link to connect our TikTok account
    https://www.tiktok.com/v2/auth/authorize?client_key=…
  4. Ask Codex

    Codex calls the tools in order and stops to explain anything it can't fix, like an expired login.

    › Retry yesterday's failed posts. If one can't be retried, tell me why.
    └ published · instagram.com/p/DC9xK… · 1 credit

Codex questions

Something not here? Email hello@postkey.dev. I answer every one myself.

Book a 15-minute call
  • It is the most reliable way to send the x-access-key header from Codex today. It runs on your machine through npx and forwards each call to the hosted server.

  • No. Each tool call costs the same credits as the API call behind it: 1 per network, 5 on X (50 with a link). Listing accounts, reading posts and moving scheduled posts cost nothing.

  • Only if you let it. Clients ask before each tool call unless you turn on auto-approve. To review every post, ask the agent to save drafts. Drafts cost nothing, and you publish them from the dashboard.

  • In your own client config. It is only sent to mcp.postkey.dev over HTTPS. Make a separate key for each agent, so you can revoke one without touching the others.

Give your agent a key.

$ curl -X POST api.postkey.dev/v1/posts -H "x-access-key: …"

No card required.