Graph API Version

Thread /{thread-id}

As part of the V3.3 changes the read_page_mailboxes permission was deprecated. Use pages_messaging permission to access this endpoint. The read_page_mailboxes permission will stop working after December 31 2019

A Facebook Messages conversation thread. This endpoint is only accessible for users that are developers of the app making the request. Pages should use the Conversation object.

Reading

Graph API Explorer
GET /v5.0/{thread-id} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{thread-id}',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{thread-id}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{thread-id}",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{thread-id}"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

  • A page access token with pages_messaging permission for any threads involving that person.
  • The user must be a tester, developer, or admin of the app making the request.

Fields

Name Description Type

id

The unique ID for this message thread.

string

comments

The messages in this thread.

Message[]

to

Profiles that are subscribed to the thread.

Profile[]

unread

The amount of messages that are unread by the session profile.

integer

unseen

The amount of messages that are unseen by the session profile.

integer

updated_time

When the thread was last updated.

datetime

can_reply

Can the page reply in the thread.

boolean

Edges

Name Description

messages

List of individual messages in the thread. See Messages

Filtering Messages

The messages connection can be filtered to avoid pulling text that is part of thread warnings by the Messenger Apps. This is done via the source filter there only participants might be selected.

If this filter is not apply admin text (gray text appears in the thread by Messenger) will be retrieved as well.

Example Call

This call will retrieve the last 3 messages made only by the participants.

curl -i -X GET \
 "https://graph.facebook.com/v4.0/t_10155839492600149?fields=id,messages.source(PARTICIPANTS).limit(3)&access_token=<Access Token>"

Publishing

You can't create a thread using the Graph API.

Deleting

You can't delete a thread using the Graph API.

Updating

You can't update a thread using the Graph API.