Getting Started

With the Pages API people can update and manage Facebook Pages from your page-related app. People can publish content to Facebook or Messenger with a Page's identity. Use cases for Pages API include:

  • Building a Pages management tool for customers or for your company
  • Building apps so content creators and editors can easily publish as a Page
  • Marketing and advertising for a business using the Marketing API. For more information, see Ads Management API and Unpublished Page Posts

Overview

1. Create a Page

2. Developer Account

3. Create a Facebook App

4. Select your Tools

5. Ask for Permissions

6. Get a Page Access Token

7. Post as a Page


1. Create a Page

Use an existing page or create a new one. For full instructions, see Help Center, How do I create a Page?


2. Developer Account

If you don't have a Facebook developer account, you will need to create one. A Facebook developer account will give you access to our developer tools and allow you to create Facebook apps.


3. Create a Facebook App

Access to the Marketing API requires you create a Facebook App ID. The App ID is used when making API calls.


4. Select Your Tools

Choose one of the following tools:

Graph API Explorer - Test Pages API using the Graph API Explorer tool. Learn more about using the Graph API Explorer.

Facebook SDKs - If you want to go beyond testing select one or more of our SDKs. Our SDKs give you easy access to the Graph API as well as Facebook Login which you will need to get access tokens.


5. Ask for Permissions

You app needs to ask for permissions to manage a page or post as a page.

In the Graph API Explorer or via using one of our SDKs ask for the following permissions:

  • manage_pages - Enables your app to retrieve Page Access Tokens for the Pages and Apps that the person administrates.
  • publish_pages - Gives your app the ability to post, comment, and like as any of the Pages managed by a person using your app.

Tip: In the Graph API Explorer select permissions by clicking Get Token, then Get User Access Token.

Advanced Permissions

In this getting started guide we will only use the basic permissions manage_pages and publish_pages. To learn more about the advanced permissions read_page_mailboxes, pages_show_list, and pages_manage_cta read our Page Access Tokens & Permissions guide.


6. Get a Page Access Token

Now that you have a User Access Token with the needed permissions, you can get a Page Access Token. Make an API request using your user access token. Replace {page-id} with your Facebook Page ID.

GET https://graph.facebook.com/{page-id}?fields=access_token

The response will look like this:

{
  "access_token": "CAACEdEose0cBACCZBZA5qz1ZBjUX...", 
  "id": "{page-id}"
}

The access_token field contains the Page Access Token for the requested page. Use it to manage the Page, post as a Page, and so forth. Learn more about Page Access Tokens and Permissions.


7. Post as a Page

Now you can make a post as the Page. Send a POST request to the /{page-id}/feed endpoint using the message field to define your message text. You can do this using the Graph API Explorer to test and to show you the code you can use.

Graph API Explorer Request and Response - The id returned is the message_id.

To get a list of page_ids in the Graph API Explorer send a GET request to me?fields=id,name,accounts where me is you with your User Access Token. This will return a list of pages you manage.

The Result in Your Page Feed

Getting the Code Snippet - At the bottom of the Graph API Explorer you can get the code for this, or any, request.

The Code Snippet - Select Android, iOS, JavaScript, PHP, or cURL.

You can also verify that your post was published by sending a GET request to the /{page-id}/feed endpoint.