This document shows you how to request permission from a person to send marketing messages, about the specific requirements and limitations for sending requests, and how to create and send marketing messages permissions requests.
Message Frequency
Beginning January 31, 2023, the notification_messages_frequency
is deprecated and message frequency will no longer be required when sending opt in requests for marketing messages.
notification_messages_frequency
will be returned in the Messaging Opt In Webhook Notification.Token Expiration and Re-Opt In
Beginning August 10, 2023, notification tokens will no longer expire. Re-opt in requests and opt out reminders will also no longer be sent.
Marketing Messages allows a Facebook Page or Instagram Professional Account to send messages outside the standard messaging window for people who have given you permission to do so. Marketing Messages allow you to build relationships with people who are interested in you or your business.
Marketing Messages is a new, optional premium feature that we intend to charge for in the future. We currently charge businesses to send messages from the WhatsApp Business API and listen to customer feedback to guide decisions on our pricing model. We will inform customers and partners of any changes to the free trial with ample advance notice.
You must comply with all applicable Developer Policies when using Marketing Messages or other Messenger Platform features
You may only send a request for a user to opt in to Marketing Messages within the standard messaging window. A user’s action of opting in to Marketing Messages does not open the standard messaging window
Your app and/or messaging experience must not receive excessive negative feedback from users. Messaging capabilities may be restricted or removed if we determine your app’s messaging experience has received excessive rates of negative feedback from users
You must not use Marketing Messages, including opt in requests, to spam users. This includes sending duplicate opt in requests at high frequencies to the same user or users and other types of spam as defined by our Developer Policies
You must respect the limitations we have placed on the functionality of Messenger Platform and Marketing Messages in order to maintain the scope of service we are providing you
title
for notifications from a Facebook Page or the same title
and image_url
for notifications from an Instagram Professional accountThese requirements and limitations are subject to change as we are always striving for the best user and business experience.
You should send people relevant, valuable Marketing Messages, in order to create a high-quality user experience by doing the following:
Your opt in request, including the title and image, encompasses the types of Marketing Messages users can expect to receive, such as order updates, product recommendations, or certain offers
When sending more than one opt in request to a user, each opt in request should clearly state the different, specific types of Marketing Messages the user can expect to receive
Marketing Messages should be relevant and tailored to use cases that a user is likely to find valuable.
Users can provide feedback on your messaging experience, including blocking your messaging, which may result in restrictions on your use of Marketing Messages. You should regularly review your opt in requests and Marketing Messages to see if they meet the best practices above.
Applies to notification message tokens created before February 2, 2023.
A person must give permission, opt in, to receive marketing messages from your Facebook Page or Instagram Professional account. The Messenger Platform offers multiple ways for you to get opt in. You can build opt in requests into the following messaging experiences:
m.me
Links
– when a person clicks your m.me
link on your website, emails, social media posts, and more
m.me
Links)
To send a marketing message opt in request, send a POST
request to the /PAGE-ID/messages
endpoint with the message template type set to notification_messages
. The Page ID is the ID for your Facebook Page or the Facebook Page linked to your Instagram Professional account.
Note: The title
parameter is required for marketing messages that contain a carousel from your
Facebook Page
or
Instagram Professional account
.
curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{ "id":"PSID-OR-IGSID" }, "message":{ "attachment":{ "type":"template", "payload":{ "template_type":"notification_messages", "notification_messages_timezone": "UTC", "title":"TITLE", "image_url":"IMAGE-URL", "payload": "ADDITIONAL-WEBHOOK-INFORMATION", } } } }' "https://graph.facebook.com/LATEST-API-VERSION/PAGE-ID/messages?access_token=PAGE-ACCESS-TOKEN"
On success, your app receives the following JSON response which includes a IDs for the recipient and the message.
{ "recipient": { "id":"PSID-OR-IGSID", "message_id":"MESSAGE-ID", }
A message
attachment
JSON object must be included in the POST
request to the /PAGE-ID/messages
endpoint for a marketing message opt in request.
Property | Description |
---|---|
template } | Required. Value must be |
| Contents of the marketing message including template type, title, message frequency, message options and more, for this marketing message opt in request |
elements array | Required for carousel. An array containing element objects that describe the opt in. Each element object must contain |
image_aspect_ratio enum { HORIZONTAL , SQUARE } | Aspect ratio for the image.
|
image_url string | The URL for the image to display in the template |
notification_messages_frequency enum { DAILY, WEEKLY, MONTHLY } | Deprecated for tokens created after February 2, 2023. Defaults to DAILY. Message frequency for this marketing message opt in request.
|
notification_messages_cta_text enum { ALLOW, GET, GET_UPDATES, OPT_IN, SIGN_UP } | Text that appears on call to action button
|
notification_messages_timezone string | Timezone for the person receiving the message |
payload string | Required. The type of marketing message, such as promotional messaging or product release messaging, for this marketing message opt in request |
template_type enum { notification_messages } | Required. Value must be |
title string | The title to display in the template, can not exceed 65 characters. If no value is assigned, the value defaults to "Updates and promotions" |
When a person opts in, your business will receive a messaging_optin
webhooks notification with a notification message token and information such as message title and timezone of the person who opted in. The notification message token allows you to send marketing messages to the person.
{ "sender": { "id": "PSID", }, "recipient": { "id": "PAGE-ID", }, "timestamp": "TIMESTAMP", "optin": { "type": "notification_messages", "payload": "ADDITIONAL-WEBHOOK-INFORMATION", "notification_messages_token": "NOTIFICATION-MESSAGES-TOKEN", "notification_messages_timezone": "TIMEZONE-ID", "token_expiry_timestamp": "TIMESTAMP", "user_token_status": "TOKEN-STATUS" "notification_messages_status": "MESSAGE-STATUS", "title": "TITLE-FOR-THE-NOTIFICATION" } }
The following content only applies to notification message tokens with a weekly or monthly frequency created before February 2, 2023.
Notification message tokens are generated per recurring frequency. For example, if a person has opted in to both daily and weekly marketing messages, two separate notification message tokens are generated. If the user opted-in to daily, weekly, and monthly Marketing Messages, then three separate notification message tokens will be generated.
marketing message Frequency | Description |
---|---|
Weekly | You can only send one message once every calendar week. A week is defined as from Monday at 12:00am until Sunday at 11:59pm in the time zone set by the Page. |
Monthly | You can only send one message once every calendar month. A month is defined as from the first day of the month at 12:00am until the last day of the month at 11:59pm in the time zone set by the Page. |
Token expiration dates will be extended for people who choose to stay opted in to receiving marketing messages. People can opt out at any time.
Once a person has opted in to receiving marketing messages, you can send up to three followup messages. These messages must be sent within two minutes of the first followup message. The second and third followup messages can not exceed 250 characters. These followup messages can be sent outside the standard 24 hour messaging window.
To send a followup message, send a POST
request to the /PAGE-ID/messages
endpoint with the recipient
object containing the notification message token and message
object containing the text of the followup messages. The syntax for the API requests for all three followup message is the same.
curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{ "notification_messages_token":"NOTIFICATION-MESSAGE-TOKEN" }, "message":{ "text":FOLLOWUP-MESSAGE-TEXT-HERE, } }' "https://graph.facebook.com/LATEST-API-VERSION/PAGE-ID/messages?access_token=TOKEN"
To get a list of all valid notification message tokens send a GET
request to the /PAGE-ID/notification_message_tokens
endpoint.
curl -i -X GET "https://graph.facebook.com/API-VERSION-NUMBER/PAGE-ID/notification_message_tokens ?access_token=PAGE-ACCESS-TOKEN"
A list of up to 25 tokens is returned by default and are ordered by updated time. To read more you can add the limit
parameter. Currently, there is a limit of 100 tokens that can be returned. You can use the after
parameter for pagination however the before
parameter is not available.
On success, your app will receive the following JSON response including the token, the recepient ID either an Instagram-scoped ID or Page-scoped ID, the time when the token was created, the title for the notification, and the time at which you can send the next marketing message to that recipient.
{ "data":[ { "notification_messages_token":"NOTIFICATION-MESSAGE-TOKEN-ID-1", "recipient_id":"PAGE-OR-INSTAGRAM-SCOPED-ID-1", "notification_messages_reoptin":"RE-OPT-IN-STATUS", "creation_timestamp":TIMESTAMP, "token_expiry_timestamp":UNIX-TIMESTAMP-EXPIRATION-DATE, "user_token_status":"TOKEN-STATUS", "topic_title":"NOTIFICATION-TITLE", "notification_messages_timezone":"TIMEZONE-ID", "next_eligible_time": TIMESTAMP }, ... { "notification_messages_token":"NOTIFICATION-MESSAGE-TOKEN-ID-25", "recipient_id":"PAGE-OR-INSTAGRAM-SCOPED-ID-25", "notification_messages_reoptin":"RE-OPT-IN-STATUS", "creation_timestamp":TIMESTAMP, "token_expiry_timestamp":UNIX-TIMESTAMP-EXPIRATION-DATE, "user_token_status":"TOKEN-STATUS", "topic_title":"NOTIFICATION-TITLE", "notification_messages_timezone":"TIMEZONE-ID", "next_eligible_time": TIMESTAMP } ], "paging":{"cursors":{"before":"QVFIU...","after":"QVFIU..."},"next":"https:\/\/graph.facebook.com\/LATEST-API-VERSION\/PAGE-ID\/notification_message_tokens?access_token=PAGE-ACCESS-TOKEN"} }
While we recommend using the messaging_optin
webhook to gather marketing message information, you can send a GET
request to the token endpoint where your token is appended to notification_messages_
, notification_messages_NOTIFICATION-MESSAGES-TOKEN
, to get token information.
curl -i -X GET "https://graph.facebook.com/LATEST-API-VERSION/notification_messages_NOTIFICATION-MESSAGES-TOKEN ?access_token=PAGE-ACCESS-TOKEN"
On success, your app will receive the following JSON response which includes the notification messages token, the ID for the person receiving the message, and other token information. You will use the notification messages token and recipient's ID send marketing messages.
{ "notification_messages_token": "NOTIFICATION-MESSAGES-TOKEN", "recipient_id": "PAGE-OR-INSTAGRAM-SCOPED-ID", "creation_timestamp": "TIMESTAMP", "token_expiry_timestamp": "TIMESTAMP", "user_token_status": "REFRESHED", "notification_messages_reoptin": "ENABLED", "notification_messages_timezone": "TIMEZONE-ID" "next_eligible_time": TIMESTAMP }
These API calls will count against your app's rate limit.
You will need:
MESSAGING
task on the Pagepages_messaging
permission, using Facebook Loginmessaging_referrals
webhook subscription for your appTo send a marketing message, send a POST
request to the /PAGE-ID/messages
endpoint with the recipient NOTIFICATION-MESSAGES-TOKEN
value and message information in the message attachment.
curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{ "notification_messages_token": "NOTIFICATION-MESSAGES-TOKEN" }, "message":{ "attachment":{ "type":"template", "payload":{ "template_type":"generic", "elements":[ { "title":"Welcome!", "image_url":"https://raw.githubusercontent.com/fbsamples/original-coast-clothing/main/public/styles/male-work.jpg", "subtitle":"We have the right hat for everyone.", "default_action": { "type": "web_url", "url": "https://www.originalcoastclothing.com/", "webview_height_ratio": "tall" }, "buttons":[ { "type":"web_url", "url":"https://www.originalcoastclothing.com/", "title":"View Website" },{ "type":"postback", "title":"Start Chatting", "payload":"ADDITIONAL-WEBHOOK-INFORMATION" } ] } ] } } } }' "https://graph.facebook.com/LATEST-API-VERSION/PAGE-ID/messages?access_token=PAGE-ACCESS-TOKEN"
Upon success your app will receive the following response:
{ "recipient": "PAGE-OR-INSTAGRAM-SCOPED-ID", "message_id": "MESSAGE-ID" }
You can test your marketing messages at any time.
You will need:
You can test your marketing messages at any time by following these steps.
developer_action
parameter set to ENABLE_FOLLOWUP_MESSAGE
.curl -X POST "https://graph.facebook.com/LATEST-API-VERSION/PAGE-ID/notification_messages_dev_support ?recipient={ "notification_messages_token": "NOTIFICATION-MESSAGES-TOKEN" } &developer_action=ENABLE_FOLLOWUP_MESSAGE &access_token=PAGE-ACCESS-TOKEN"
On success, your app will receive the following JSON response containing success
set to true
.
{ "success": true }
To test re-opt ins, repeat the steps with the developer_action
parameter set to SEND_RE_OPTIN
in Step 4.