Facebook

How to Post to a Facebook Page via API

The request flow for posting to a Facebook Page programmatically, including required admin access.

Quick answer

Posting to a Facebook Page via API takes four calls through PostGate: create a hosted connection URL and have a Page admin authorize it, list profiles to get the resulting profile_id, publish with POST /api/posts and a stable Idempotency-Key, then read the post back to confirm delivery. No Graph API SDK, no token handling on your side.

This is the full request flow, end to end: connect a Page you administer, find its profile ID, publish a post, and confirm it actually went out. Four calls, no Graph API SDK, no token handling on your side.

01

Step 1 — Connect the Page

Create a hosted connection URL and redirect your customer's browser to it. They need to be an admin (or hold an equivalent task) on the Facebook Page — a personal profile can't be the destination. The URL expires after 15 minutes.
Create a connection URLPostGate API
curl -X POST https://postgate.studio/api/profiles/connect \
  -H "Authorization: Bearer $POSTGATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "facebook",
    "profile_group_id": "grp_acme123",
    "return_url": "https://app.example.com/settings/social"
  }'
02

Step 2 — Confirm the connection and find the profile ID

After the customer authorizes the Page, PostGate redirects back to your return_url with connected=1&connection_platform=facebook. List profiles for the group to read the resulting profile_id — you'll need it for every post you publish to that Page.
List connected profilesPostGate API
curl "https://postgate.studio/api/profiles?profile_group_id=grp_acme123" \
  -H "Authorization: Bearer $POSTGATE_API_KEY"
03

Step 3 — Publish the post

Send the body, the profile ID, and any media in one call. Include a stable Idempotency-Key so a dropped connection and a retry never publish the same post twice — PostGate honors the key for 72 hours.
Publish nowPostGate API
curl -X POST "https://postgate.studio/api/posts?profile_group_id=grp_acme123" \
  -H "Authorization: Bearer $POSTGATE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: launch-post-001" \
  -d '{
    "post": { "body": "We just shipped something new." },
    "profiles": ["pro_facebook789"],
    "media": ["https://cdn.example.com/launch.jpg"]
  }'
04

Step 4 — Confirm delivery

The create response is acceptance, not proof. Read the post back to see each target's terminal status and permalink, or — better — subscribe to a webhook instead of polling. A failed target carries a structured error you can act on; awaiting_reconnect means the customer needs to reconnect the Page.
Inspect the postPostGate API
curl https://postgate.studio/api/posts/post_01JXYZ \
  -H "Authorization: Bearer $POSTGATE_API_KEY"
05

Why is admin access non-negotiable?

Meta requires a Page access token carrying pages_manage_posts, sourced from a user with an admin-equivalent task on the Page — and Meta requires the app itself to complete App Review and Business Verification before that permission works for anyone outside the app's own roles. See Facebook Page access token for the token mechanics.

Frequently asked questions

Can I post to a personal Facebook profile via API?

No — a personal profile can’t be the destination. The person connecting needs to be an admin (or hold an equivalent task) on a Facebook Page, and posts publish to that Page. The connection runs through a hosted URL that expires after 15 minutes.

Why does posting to a Facebook Page require admin access?

Meta requires a Page access token carrying pages_manage_posts, sourced from a user with an admin-equivalent task on the Page — and Meta requires the app itself to complete App Review and Business Verification before that permission works for anyone outside the app’s own roles.

How do I stop a retry from publishing the same Facebook post twice?

Include a stable Idempotency-Key header on the publish call. PostGate honors the key for 72 hours, so a dropped connection followed by a retry never publishes the same post twice.

How do I confirm a Facebook Page post actually went out?

The create response is acceptance, not proof. Read the post back to see each target’s terminal status and permalink, or — better — subscribe to a webhook instead of polling. A failed target carries a structured error you can act on; awaiting_reconnect means the customer needs to reconnect the Page.

Build it with PostGate

One API for every social platform your customers care about — sandboxed, documented, and ready today.

Start building Read the docs