The User Profile API allows you to use a Page-scoped ID (PSID) to retrieve user profile information that can be used to personalize the experience of people interacting with your Messenger.
Though a PSID may be valid, in some cases it may not be able to be used to retrieve a person's profile information. For example PSIDs associated with Instant Games Pages are not accessible via the User Profile API.
The following events will authorize your Messenger bot to access a person's profile information:
askPermission() function of the Messenger Extensions SDK in the webview to ask for the
Some entry points allow apps to initiate a conversation without granting the app authorization to access the person's public profile. In those cases, the app will be granted permission to access the person's profile after the person replied to the initial message. Notable situations where a person may initiate a conversation with the app, but not authorize profile permission include the following:
Currently, the User Profile API does not support retrieving profile information for Messenger accounts that were created using a phone number.
In this case, the API will return the error code
2018218 along with the message 'No profile available for this user.'
Apps that have received App Review approval for the required feature and permission may retrieve the following fields for users who have made this information public and have opted-in to your Page.
|Feature or Permission Required for Access
The user's PSID
The user's first and last name
URL to the Profile picture. The URL will expire.
Locale of the user on Facebook. For supported locale codes, see Supported Locales.
Timezone, number relative to GMT
To use the User Profile API, send a
GET request with the profile fields you want for the person:
curl -X GET "https://graph.facebook.com/<PSID>?fields=first_name,last_name,profile_pic&access_token=<PAGE_ACCESS_TOKEN>"
If the app is able to access the person's profile, the User Profile API will return a JSON string with the requested fields from the person's profile.
If the app is unable to access the person's profile, an empty object is returned.