Skip to main content
Back to all posts

How to Post on Facebook With an API in 2026 (Step-by-Step)

·6 min read·Jonathan Geiger
facebook apitutorialposting api2026

Facebook's Graph API for posting still works fine, but it's tedious. You sign up for a Meta developer account, register an app, go through App Review for each permission you need (pages_show_list, pages_read_engagement, pages_manage_posts), wait weeks, then build the OAuth-to-Page-list flow and figure out per-Page tokens vs user tokens vs short-lived vs long-lived.

Posting to a personal profile? Deprecated years ago. Pages only.

PostPeer gives you a single endpoint that handles all of that. OAuth is done for you. Page discovery is done for you. App Review is done for you. Here's how to set it up.

What you need

  • A PostPeer account (free tier works)
  • Your access key from the dashboard
  • A Facebook Page you administer

Step 1: Get your API key

Sign up at PostPeer, head to the dashboard, and grab your access key from the Access Keys page. Every request uses the x-access-key header:

-H "x-access-key: YOUR_API_KEY"

Grab your API key from the Access Keys page in your dashboard. Treat it like a password.

PostPeer Access Keys

Step 2: Connect your Facebook Page

PostPeer handles the OAuth flow. Hit the connect endpoint to get an authorization URL:

curl https://api.postpeer.dev/v1/connect/facebook \
  -H "x-access-key: YOUR_API_KEY"

You'll get back a URL. Open it in a browser, authorize the app, and pick which Pages PostPeer can post to. Every Page you select becomes its own integration with its own ID. Grab them from the integrations endpoint:

curl https://api.postpeer.dev/v1/connect/integrations \
  -H "x-access-key: YOUR_API_KEY"

The response includes an id for each connected Page. That's your accountId for posting. You can also do this from the PostPeer dashboard if you'd rather click a button.

PostPeer Integrations Dashboard

Step 3: Post a text update

The simplest Facebook post. Just text:

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Shipping a new feature today. Details on our blog →",
    "platforms": [
      {
        "platform": "facebook",
        "accountId": "your-page-id"
      }
    ],
    "publishNow": true
  }'

PostPeer routes this to the Page's /feed endpoint with the Page token resolved from the saved integration. The response includes the published post URL. Facebook's hard caption ceiling is 63,206 characters, but realistically nobody pastes a novel into a Page post.

Step 4: Post an image (or carousel)

Pass image media items. One image goes straight to /photos. Multiple images are uploaded as published=false, their IDs collected, then posted to /feed with attached_media:

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Behind the scenes from this week'\''s launch →",
    "platforms": [
      { "platform": "facebook", "accountId": "your-page-id" }
    ],
    "mediaItems": [
      { "type": "image", "url": "https://your-cdn.com/photo-1.jpg" },
      { "type": "image", "url": "https://your-cdn.com/photo-2.jpg" },
      { "type": "image", "url": "https://your-cdn.com/photo-3.jpg" }
    ],
    "publishNow": true
  }'

Facebook supports up to 10 photos per Page post.

Step 5: Post a video

Same shape, swap type: "image" for type: "video":

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Quick demo of the new dashboard.",
    "platforms": [
      { "platform": "facebook", "accountId": "your-page-id" }
    ],
    "mediaItems": [
      { "type": "video", "url": "https://your-cdn.com/demo.mp4" }
    ],
    "publishNow": true
  }'

PostPeer routes video posts to the Page's /videos endpoint. Facebook handles the encoding and thumbnail generation server-side.

Pass the URL in platformSpecificData.link. Facebook fetches Open Graph tags from that URL and renders a rich link card:

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Long read on our latest launch.",
    "platforms": [
      {
        "platform": "facebook",
        "accountId": "your-page-id",
        "platformSpecificData": {
          "link": "https://www.postpeer.dev/blog/best-facebook-posting-api"
        }
      }
    ],
    "publishNow": true
  }'

If the target URL has proper og:title, og:image, and og:description tags, Facebook turns it into a rich preview card. If it doesn't, you get a plain text post with the URL.

You can also set "published": false in platformSpecificData to create the post in unpublished/draft state on the Page (useful for staging or scheduling via Facebook's own composer).

Scheduling a Facebook post

Replace publishNow with scheduledFor and timezone. The post sits in a queue and goes out at the right moment:

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Weekly product update going live Monday morning.",
    "platforms": [
      { "platform": "facebook", "accountId": "your-page-id" }
    ],
    "scheduledFor": "2026-06-15T09:00:00",
    "timezone": "America/New_York"
  }'

Scheduled and published posts show up in the Posts dashboard, where you can filter by status, platform, and date.

The free social media poster is the same API behind a UI. Useful for testing the flow before wiring it into code.

Cross-post to Facebook + Instagram + LinkedIn

The whole point of a multi-platform API. One post, three platforms, one request:

curl -X POST https://api.postpeer.dev/v1/posts \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "New launch is live. Try it free →",
    "platforms": [
      { "platform": "facebook", "accountId": "your-page-id" },
      { "platform": "instagram", "accountId": "your-ig-id" },
      { "platform": "linkedin", "accountId": "your-li-id" }
    ],
    "mediaItems": [
      { "type": "image", "url": "https://your-cdn.com/launch.jpg" }
    ],
    "publishNow": true
  }'

PostPeer adapts the upload flow per platform. Facebook hits /photos. Instagram does the container plus publish dance. LinkedIn handles its own images endpoint. From your side, it's one request.

Pulling Facebook analytics

PostPeer also exposes a Facebook Analytics API on the same /v1/analytics endpoint. Likes, comments, and shares per Page post:

curl "https://api.postpeer.dev/v1/analytics?source=platform&platform=facebook&accountId=your-page-id&limit=20" \
  -H "x-access-key: YOUR_API_KEY"

Each call costs 1 credit regardless of how many posts come back.

What's next

That covers text posts, image carousels, video, link previews, scheduling, and cross-posting. If you're building anything that posts to Facebook at scale, this is the fastest way there.

Full reference is on the Facebook posting API page. Edge cases and advanced options are in the API docs.

If you're just getting started, the free tier includes 20 posts so you can test the whole flow without paying. Or play with the free social media poster for a no-code version.