Back to all posts

How to Post to Multiple Social Media Platforms With One API

·Jonathan Geiger
tutorialapicross-posting

Publishing content across multiple social media platforms is one of the most common requirements for modern apps. Whether you're building a social media scheduler, a SaaS product with social features, or an AI content generator, you need a reliable way to post to Twitter, Instagram, YouTube, TikTok, and more — without maintaining separate integrations for each platform.

In this guide, we'll walk through how to use PostPeer's API to publish content to multiple platforms with a single HTTP request.

Prerequisites

Before you start, you'll need:

  • A PostPeer account (sign up for free)
  • An API key from your PostPeer dashboard
  • At least one connected social media account

Step 1: Get Your API Key

After signing up, navigate to your PostPeer dashboard. You'll find your API key in your project settings. This key authenticates all your API requests.

# Your API key looks like this
x-access-key: pp_live_abc123...

Step 2: Connect Social Accounts

Before you can post, your users need to connect their social media accounts. PostPeer handles the OAuth flow for each platform — you don't need to set up developer apps on Twitter, Facebook, or any other platform.

Each connected account gets a unique accountId that you'll use when targeting platforms in your API requests.

Step 3: Make Your First Post

Here's how to publish the same content to Twitter, Instagram, and Facebook with a single request:

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Just shipped a new feature! Check it out.",
    "platforms": [
      { "platform": "twitter", "accountId": "acc_tw_123" },
      { "platform": "instagram", "accountId": "acc_ig_456" },
      { "platform": "facebook", "accountId": "acc_fb_789" }
    ]
  }'

PostPeer returns a response with per-platform results:

{
  "postId": "post_abc123",
  "status": "published",
  "platforms": [
    {
      "platform": "twitter",
      "status": "published",
      "platformPostUrl": "https://x.com/youruser/status/123456789"
    },
    {
      "platform": "instagram",
      "status": "published",
      "platformPostUrl": "https://instagram.com/p/abc123"
    },
    {
      "platform": "facebook",
      "status": "published",
      "platformPostUrl": "https://facebook.com/post/789"
    }
  ]
}

Step 4: Add Media

PostPeer supports images, videos, GIFs, and carousels. Pass media URLs in the mediaItems array:

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Our new office setup!",
    "mediaItems": [
      { "url": "https://example.com/photo.jpg", "type": "image" }
    ],
    "platforms": [
      { "platform": "twitter", "accountId": "acc_tw_123" },
      { "platform": "instagram", "accountId": "acc_ig_456" }
    ]
  }'

PostPeer validates media against each platform's requirements (dimensions, file size, format) before publishing.

Step 5: Use Platform-Specific Options

Some platforms support unique features. You can pass platform-specific data alongside your content:

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Thread about our launch...",
    "platforms": [
      {
        "platform": "twitter",
        "accountId": "acc_tw_123",
        "platformSpecificData": {
          "threadItems": [
            { "text": "1/ We just launched PostPeer..." },
            { "text": "2/ It supports 7+ platforms..." },
            { "text": "3/ Try it free at postpeer.dev" }
          ]
        }
      },
      { "platform": "threads", "accountId": "acc_th_456" }
    ]
  }'

This posts a thread on Twitter while publishing a single post on Threads.

Error Handling

If a post fails on one platform, PostPeer still publishes to the others. You get per-platform status in the response:

{
  "postId": "post_abc123",
  "status": "partial",
  "platforms": [
    {
      "platform": "twitter",
      "status": "published",
      "platformPostUrl": "https://x.com/youruser/status/123456789"
    },
    {
      "platform": "instagram",
      "status": "failed",
      "error": "Image aspect ratio not supported"
    }
  ]
}

Failed posts don't count against your quota, so you can retry with adjusted content.

What's Next

  • Schedule posts: Add a publish_at timestamp to schedule content for later
  • Set up webhooks: Get real-time notifications when posts publish or fail
  • Pull analytics: Fetch engagement data for published posts

Check out the PostPeer docs for the full API reference, or sign up for free to start building.