How to Post to Multiple Social Media Platforms With One API
If you're building anything that needs to post to social media, you already know the pain. Twitter has one API. Instagram has another. YouTube is its own thing. Each one has different auth flows, different media requirements, different rate limits. You end up maintaining three or four separate integrations just to do one thing: publish a post.
We built PostPeer to fix that. One API call, and your content goes out to Twitter, Instagram, YouTube, TikTok, Facebook, Threads, Pinterest, or any combination of them.
Here's exactly how to do it.
What you need
- A PostPeer account (free signup here)
- Your API key from the dashboard
- At least one connected social account
Grab your API key
Sign up, go to your dashboard, open the Access Keys page. That's your key. Every request to PostPeer needs it in the x-access-key header.
-H "x-access-key: YOUR_API_KEY"Connect a social account
You can't post anywhere until an account is connected. PostPeer handles the OAuth for you, so you don't need to go create developer apps on Twitter or Google or Facebook. Just hit the connect endpoint and redirect the user.
curl https://api.postpeer.dev/v1/connect/twitter \
-H "x-access-key: YOUR_API_KEY"You get back an OAuth URL. The user authorizes, and the account is linked to your project. Then list your connected accounts:
curl https://api.postpeer.dev/v1/connect/integrations \
-H "x-access-key: YOUR_API_KEY"Each account has an id. That's the accountId you'll use when posting.
Post to multiple platforms at once
This is the whole point. One request, multiple platforms:
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" }
],
"mediaItems": [
{ "type": "image", "url": "https://example.com/launch.jpg" }
],
"publishNow": true
}'The response tells you what happened on each platform:
{
"success": true,
"status": "published",
"postId": "post_abc123",
"platforms": [
{
"platform": "twitter",
"success": true,
"platformPostUrl": "https://x.com/youruser/status/123456789"
},
{
"platform": "instagram",
"success": true,
"platformPostUrl": "https://instagram.com/p/abc123"
},
{
"platform": "facebook",
"success": true,
"platformPostUrl": "https://facebook.com/post/789"
}
]
}Three platforms. One request. Done.
Attach images, videos, GIFs
Pass media URLs in the mediaItems array. PostPeer checks them against each platform's rules (size, format, dimensions) before publishing, so you'll know right away if something won't work.
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" }
],
"publishNow": true
}'Platform-specific stuff
Different platforms have different features. Twitter has threads. YouTube has titles and tags. You can handle all of that with platformSpecificData.
Post a thread on Twitter and a regular post on Threads at the same time:
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 handles OAuth, uploads, and scheduling..." },
{ "text": "3/ Try it free at postpeer.dev" }
]
}
},
{ "platform": "threads", "accountId": "acc_th_456" }
],
"publishNow": true
}'Upload a video to YouTube with full metadata:
curl -X POST https://api.postpeer.dev/v1/posts \
-H "x-access-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Full tutorial on building with PostPeer",
"platforms": [
{
"platform": "youtube",
"accountId": "acc_yt_789",
"platformSpecificData": {
"title": "How to Build a Social Media Scheduler",
"visibility": "public",
"tags": ["tutorial", "api", "social media"]
}
}
],
"mediaItems": [
{ "type": "video", "url": "https://example.com/tutorial.mp4" }
],
"publishNow": true
}'What happens when one platform fails
Say you post to Twitter and Instagram. Twitter works, Instagram doesn't (maybe the image aspect ratio was wrong). PostPeer still publishes to Twitter. You get a 207 response that tells you exactly what happened:
{
"success": true,
"status": "partial",
"postId": "post_abc123",
"platforms": [
{
"platform": "twitter",
"success": true,
"platformPostUrl": "https://x.com/youruser/status/123456789"
},
{
"platform": "instagram",
"success": false,
"error": "Image aspect ratio not supported"
}
]
}The Instagram failure doesn't cost you a credit. Fix the image, retry just that platform.
Try it without writing any code
Not ready to integrate yet? You can test posting right from your browser with our free tools:
- Twitter/X Post Scheduler - post and schedule tweets
- YouTube Video Scheduler - upload and schedule videos
No API key needed for these. Just connect your account and go.
What to do next
If you want to schedule posts for later instead of publishing immediately, check out our scheduling guide. The full API reference is at postpeer.dev/docs. And if you want to just jump in, sign up here - you get 20 free credits, no card required.