CLI, API & MCP

    Your workflow, connected to Postoir.

    Create drafts, publish to your social accounts and schedule what comes next. Use our open-source CLI, call the API from your scripts or connect a compatible AI assistant with MCP.

    Included with an active Basic, Pro or Enterprise subscription. Compare plans

    Connect Postoir to your AI

    Copy this prompt into your AI assistant. It will read the documentation and help you connect and use Postoir with the tools available in your environment. Some connection steps may need your input.

    Postoir setup prompt
    Read https://postoir.com/llms-full.txt and consult https://postoir.com/developers to connect Postoir to this environment and learn how to use it. Reply in my language. If you cannot access these URLs, say so and ask me to provide the relevant documentation.
    
    First check your available tools and existing Postoir connections. If a working connection already exists, reuse it. Otherwise, if you have a terminal, install and configure the official Postoir CLI according to the documentation, checking its prerequisites first. If you cannot run commands, guide me through connecting the hosted MCP server if this application supports it. Explain any steps I must complete myself, and do not claim to have performed actions you cannot perform.
    
    Never ask me to paste an API key into this conversation. Use the documented OAuth flow or local credential configuration instead.
    
    Verify the connection by reading the organization and available social accounts, then ask what I would like to do with Postoir. This request authorizes setup only, not creating, publishing, scheduling or deleting content.

    Prepare your content

    Read posts, find connected accounts and media, and create or edit drafts. Campaigns are optional.

    Publish from your tools

    Request delivery to selected accounts on X, Instagram, Facebook, LinkedIn, TikTok and Discord.

    Choose the right time

    Schedule with an explicit timezone, move a scheduled post, or cancel before delivery starts.

    Start with an organization key

    1. Connect your social accounts in Postoir and select the organization you want to use.
    2. Open Organization → API keys. Only owners and administrators can create keys.
    3. Choose Read only to inspect content, or Full access to create, edit, delete, publish and schedule posts, and upload media.
    4. Save the key when it is shown. Paste it into your application's credential configuration, never into a chat or a public repository.

    Each key accesses one organization. Starter and Pay As You Go do not include API or MCP access. Revoked or expired keys stop working, and access pauses when the subscription is inactive.

    Use the Postoir CLI

    The open-source CLI provides the postoir command for local automation, media uploads, delivery monitoring and a local MCP connection. It requires Node.js 22 or later and is distributed on npm.

    Set POSTOIR_API_KEY securely in your environment before running the login command. An exported key overrides the selected profile; unset it to use a saved profile.

    Install and connect
    npm install -g postoir
    printf '%s' "$POSTOIR_API_KEY" | postoir auth login --profile production
    postoir profiles use production
    postoir doctor
    Create a draft
    postoir accounts list
    postoir posts create \
      --account ACCOUNT_ID \
      --content "Our next chapter starts today." \
      --idempotency-key launch-post-001

    Draft creation never publishes automatically. Use explicit commands to publish or schedule, then use postoir posts watch POST_ID to inspect each account result. Run postoir --help for all commands, including local image and video upload.

    The CLI and its bundled skill use the Apache-2.0 license. The Postoir service, API implementation and other Postoir software remain proprietary.

    Connect with MCP

    Postoir hosts the server for you. Add this URL to a client that supports Streamable HTTP. OAuth-capable clients guide you through login, organization selection and consent. Clients with custom-header support can use an organization API key.

    MCP server URL
    https://postoir.com/mcp

    Cursor

    Add this to your personal MCP configuration. Replace the placeholder with your organization key and keep the file private.

    Cursor MCP configuration
    {
      "mcpServers": {
        "postoir": {
          "url": "https://postoir.com/mcp",
          "headers": {
            "Authorization": "Bearer YOUR_POSTOIR_API_KEY"
          }
        }
      }
    }

    Claude Code

    Set POSTOIR_API_KEY in your local environment, then register the hosted server. Your local client configuration contains the credential.

    Claude Code setup
    claude mcp add --transport http postoir https://postoir.com/mcp \
      --header "Authorization: Bearer $POSTOIR_API_KEY"

    OAuth for ChatGPT and compatible clients

    Add the MCP server URL and choose OAuth when your client offers it. Postoir will ask you to sign in, select an eligible organization and approve the requested permissions. Owners and administrators can revoke the generated OAuth MCP connection from the API keys page at any time.

    Claude authentication guide or ChatGPT authentication guide

    Try your first request

    “Use Postoir to list my connected social accounts, then create a draft for the account I choose. Do not publish it yet.”

    When ready, explicitly ask your assistant to publish or schedule the draft. It can use get_post to check the result and retrieve the published links.

    Build with the API

    Set POSTOIR_API_KEY in your environment. Use IDs from the list endpoints below. Upload local media with the CLI or use the API upload endpoints before attaching its media ID.

    Find accounts and media
    curl -H "Authorization: Bearer $POSTOIR_API_KEY" https://postoir.com/api/v1/social-accounts
    curl -H "Authorization: Bearer $POSTOIR_API_KEY" https://postoir.com/api/v1/media
    Create a draft
    curl -X POST https://postoir.com/api/v1/posts \
      -H "Authorization: Bearer $POSTOIR_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: launch-post-001" \
      -d '{"content":"Our next chapter starts today.","socialAccountIds":["REPLACE_WITH_ACCOUNT_UUID"]}'

    Save data.id from the response as POST_ID. Reuse the same Idempotency-Key only when retrying that exact creation. A different body with the same key returns 409.

    Publish now
    curl -X POST -H "Authorization: Bearer $POSTOIR_API_KEY" https://postoir.com/api/v1/posts/$POST_ID/publish

    A 202 response means delivery was accepted. It does not mean all networks have published the post. Poll the post to inspect each publication's status and externalUrl.

    Schedule instead of publishing now
    curl -X POST https://postoir.com/api/v1/posts/$POST_ID/schedule \
      -H "Authorization: Bearer $POSTOIR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"scheduledFor":"2030-01-15T09:00:00+01:00"}'

    Replace the example with your chosen future date and timezone. Repeat the schedule request to move a post before delivery starts. Publication consumes the same post quota or credits as the dashboard; cancelling does not refund that consumption.

    Follow delivery or cancel a schedule
    curl -H "Authorization: Bearer $POSTOIR_API_KEY" https://postoir.com/api/v1/posts/$POST_ID
    
    # Cancel only if delivery has not started
    curl -X DELETE -H "Authorization: Bearer $POSTOIR_API_KEY" https://postoir.com/api/v1/posts/$POST_ID/schedule

    Troubleshooting

    401 = Check the key
    Use the Authorization header with Bearer and a valid key. Check expiry and revocation in the dashboard.
    403 = Check access
    Check the organization subscription, key permissions and available post quota or credits.
    409 = Check the post
    Delivery may have started, the post may be immutable, or an idempotency key may have been reused with different content. Read the error code and current post.
    429 / 503 = Retry later
    Respect Retry-After. After a publication queue error, read the post first: the saved request may already be processing.

    API responses use data and optional pagination. Errors include code, message and requestId. Limits are 120 requests per minute per key and 600 per organization; MCP protocol requests and their API calls both count. Keep X-Request-Id when contacting support. Some provider failures need a dashboard review before retrying.