We are making changes to the WhatsApp Business Platform pricing model. See Pricing Updates on the WhatsApp Business Platform.
Use the /PHONE_NUMBER_ID/messages
endpoint to send text, media, contacts, location, and interactive messages, as well as message templates to your customers. Learn more about the messages you can send.
Endpoint | Authentication |
---|---|
(請參閱取得手機號碼編號) | Developers can authenticate their API calls with the access token generated in the App Dashboard > WhatsApp > API Setup.
Solution Partners must authenticate themselves with an access token with the |
Messages are identified by a unique ID (WAMID). You can track message status in the Webhooks through its WAMID. You could also mark an incoming message as read through messages endpoint. This WAMID can have a maximum length of up to 128 characters.
To send a message, you must first assemble a message object with the content you want to send. These are the parameters used in a message
object:
名稱 | 說明(點擊左欄的箭咀以了解支援選項。) |
---|---|
|
包含音訊的 |
| 此為選用項目。 任何字串,有助追蹤。 舉例來說,您可以在此欄位輸入訊息範本編號,以從您傳送的第一則訊息開始追蹤顧客體驗歷程。然後,您可以追蹤不同訊息範本類型的投資回報率,以找出哪個類型最有效。 此字串包含在 Webhook 裝載的 雲端 API 不會處理此欄位,只會將其作為已傳送/已送達/已讀訊息 Webhooks 的一部分傳回。 最多 512 個字元。 |
|
|
| 回覆對話中任何訊息時,此為必要項目。 此物件包含您所回覆的之前訊息其編號。例如:
|
|
包含文件的 |
| 包含 僅限內部部署 API。 |
|
包含圖像的 |
|
|
|
|
| 此為必要項目 要求所用的訊息往來服務。使用 |
|
允許在文字訊息中顯示網址預覽。請參閱在文字訊息中傳送網址。如不在訊息中加入網址,此為可選欄位。值: |
| 此為選用項目。 您目前僅可向個人用戶傳送訊息。請將此設定為 預設: |
| 訊息狀態。您可使用此欄位將訊息標記為 |
|
包含貼圖的 雲端 API:除了所有傳入訊息的貼圖類型外,亦支援傳出訊息的第三方靜態和動態貼圖。靜態貼圖須為 512x512 像素,不得超過 100 KB。動態貼圖須為 512x512 像素,不得超過 500 KB。 內部部署 API:除了所有傳入訊息的貼圖類型外,僅支援傳出訊息的第三方靜態貼圖。靜態貼圖須為 512x512 像素,不得超過 100 KB。不支援動態貼圖。 |
|
|
| 此為文字訊息的必要項目。 |
| 此為必要項目。 作為訊息傳送對象的顧客之 WhatsApp 編號或手機號碼。請參閱手機號碼格式。 如有需要,內部部署 API 用戶可呼叫 |
| 此為選用項目。 要傳送的訊息類型。如略過,則預設為 |
The following objects are nested inside the message object:
Name | Description |
---|---|
| Optional. Full contact address(es) formatted as an
|
| Optional.
|
| Optional. Contact email address(es) formatted as an
|
| Required. Full contact name formatted as a
*At least one of the optional parameters needs to be included along with the |
| Optional. Contact organization information formatted as an
|
| Optional. Contact phone number(s) formatted as a
|
| Optional. Contact URL(s) formatted as a
|
Name | Description |
---|---|
| Required. Action you want the user to perform after reading the message. |
| Optional for type An object with the body of the message. The
|
| Optional. An object with the footer of the message. The
|
| Required for type Header content displayed on top of a message. You cannot set a header if your interactive object is of |
| Required. The type of interactive message you want to send. Supported values:
|
The following objects are nested inside the interactive
object:
Name | Description |
---|---|
| Required for List Messages. Button content. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. Maximum length: 20 characters. |
| Required for Reply Buttons. A button object can contain the following parameters:
You can have up to 3 buttons. You cannot have leading or trailing spaces when setting the ID. |
| Required for Single Product Messages and Multi-Product Messages. Unique identifier of the Facebook catalog linked to your WhatsApp Business Account. This ID can be retrieved via the Meta Commerce Manager. |
| Required for Single Product Messages and Multi-Product Messages. Unique identifier of the product in a catalog. To get this ID go to Meta Commerce Manager and select your Meta Business account. You will see a list of shops connected to your account. Click the shop you want to use. On the left-side panel, click Catalog > Items, and find the item you want to mention. The ID for that item is displayed under the item's name. |
| Required for List Messages and Multi-Product Messages. Array of |
| Optional for Flows Messages. The current mode of the Flow, either Default: |
| Required for Flows Messages. Must be |
| Required for Flows Messages. A token that is generated by the business to serve as an identifier. |
| Required for Flows Messages. Unique identifier of the Flow provided by WhatsApp. |
| Required for Flows Messages. Text on the CTA button, eg. "Signup". Maximum length: 20 characters (no emoji). |
| Optional for Flows Messages.
Default: |
| Optional for Flows Messages. Required only if
|
Name | Description |
---|---|
| Required if Contains the media object for this document. |
| Required if Contains the media object for this image. |
| Required if Text for the header. Formatting allows emojis, but not markdown. Maximum length: 60 characters. |
| Optional. Text for the header. Formatting allows emojis, but not markdown. Maximum length: 60 characters. |
| Required. The header type you would like to use. Supported values:
|
| Required if Contains the media object for this video. |
Name | Description |
---|---|
| Required for Multi-Product Messages. Array of Each
|
| Required for List Messages. Contains a list of rows. You can have a total of 10 rows across your sections. Each row must have a title (Maximum length: 24 characters) and an ID (Maximum length: 200 characters). You can add a description (Maximum length: 72 characters), but it is optional. Example: "rows": [ { "id":"unique-row-identifier-here", "title": "row-title-content-here", "description": "row-description-content-here", } ] |
| Required if the message has more than one section. Title of the section. Maximum length: 24 characters. |
Name | Description |
---|---|
| Required. Location latitude in decimal degrees. |
| Required. Location longitude in decimal degrees. |
| Required. Name of the location. |
| Required. Address of the location. |
See Get Media ID for information on how to get the ID of your media object. For information about supported media types for Cloud API, see Supported Media Types.
Name | Description |
---|---|
| Required when The media object ID. Do not use this field when message |
| Required when The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs. Do not use this field when message Cloud API users only:
|
| Optional. Media asset caption. Do not use with On-Premises API users:
|
| Optional. Describes the filename for the specific document. Use only with The extension of the filename will specify what format the document is displayed as in WhatsApp. |
| Optional. On-Premises API only. This path is optionally used with a |
Name | Description |
---|---|
| Required. Name of the template. |
| Required. Contains a The
|
| Optional. Array of |
| Optional. Only used for On-Premises API. Namespace of the template. |
The following objects are nested inside the template
object:
Name | Description (Click the arrow in the left column for supported options.) |
---|---|
| Required. Indicates the type of parameter for the button. |
| Required for Developer-defined payload that is returned when the button is clicked in addition to the display text on the button. See Callback from a Quick Reply Button Click for an example. |
| Required for URL buttons. Developer-provided suffix that is appended to the predefined prefix URL in the template. |
Name | Description (Click the arrow in the left column for supported options.) |
---|---|
| Required. Describes the Example of a "components": [{ "type": "body", "parameters": [{ "type": "text", "text": "name" }, { "type": "text", "text": "Hi there" }] }] |
| Required when Type of button to create. |
| Required when Array of For components of type=button, see the |
| Required when Position index of the button. You can have up to 10 buttons using index values of 0 to 9. |
Name | Description |
---|---|
| Required. Default text if localization fails. |
| Required. Currency code as defined in |
| Required. Amount multiplied by 1000. |
Name | Description |
---|---|
| Required. Default text. For Cloud API, we always use the fallback value, and we do not attempt to localize using other optional fields. |
Name | Description |
---|---|
| Required. Describes the parameter type. Supported values:
For text-based templates, the only supported parameter types are |
| Required when The message’s text. Character limit varies based on the following included component type. For the
For the
|
| Required when |
| Required when |
| Required when A |
| Required when A |
| Required when A |
Name | Description |
---|---|
| Required for text messages. The text of the text message which can contain URLs which begin with http:// or https:// and formatting. See available formatting options here. If you include URLs in your text and want to include a preview box in text messages ( Maximum length: 4096 characters |
| Optional. Cloud API only. Set to If On-Premises API users, use |
Name | Description |
---|---|
| Required. The WhatsApp Message ID (wamid) of the message on which the reaction should appear. The reaction will not be sent if:
If the ID is of a message that has been deleted, the message will not be delivered. |
| Required. Emoji to appear on the message.
|
See the following guides for full information on how to use the /messages
endpoint to send messages:
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "text",
"text": { // the text object
"preview_url": false,
"body": "MESSAGE_CONTENT"
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "reaction",
"reaction": {
"message_id": "wamid.HBgLM...",
"emoji": "\uD83D\uDE00"
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM-PHONE-NUMBER-ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE-NUMBER",
"type": "image",
"image": {
"id" : "MEDIA-OBJECT-ID"
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"to": "PHONE_NUMBER",
"type": "location",
"location": {
"longitude": LONG_NUMBER,
"latitude": LAT_NUMBER,
"name": LOCATION_NAME,
"address": LOCATION_ADDRESS
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"to": "PHONE_NUMBER",
"type": "contacts",
"contacts": [{
"addresses": [{
"street": "STREET",
"city": "CITY",
"state": "STATE",
"zip": "ZIP",
"country": "COUNTRY",
"country_code": "COUNTRY_CODE",
"type": "HOME"
},
{
"street": "STREET",
"city": "CITY",
"state": "STATE",
"zip": "ZIP",
"country": "COUNTRY",
"country_code": "COUNTRY_CODE",
"type": "WORK"
}],
"birthday": "YEAR_MONTH_DAY",
"emails": [{
"email": "EMAIL",
"type": "WORK"
},
{
"email": "EMAIL",
"type": "HOME"
}],
"name": {
"formatted_name": "NAME",
"first_name": "FIRST_NAME",
"last_name": "LAST_NAME",
"middle_name": "MIDDLE_NAME",
"suffix": "SUFFIX",
"prefix": "PREFIX"
},
"org": {
"company": "COMPANY",
"department": "DEPARTMENT",
"title": "TITLE"
},
"phones": [{
"phone": "PHONE_NUMBER",
"type": "HOME"
},
{
"phone": "PHONE_NUMBER",
"type": "WORK",
"wa_id": "PHONE_OR_WA_ID"
}],
"urls": [{
"url": "URL",
"type": "WORK"
},
{
"url": "URL",
"type": "HOME"
}]
}]
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "interactive",
"interactive": {
"type": "product",
"body": {
"text": "optional body text"
},
"footer": {
"text": "optional footer text"
},
"action": {
"catalog_id": "CATALOG_ID",
"product_retailer_id": "ID_TEST_ITEM_1"
}
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "interactive",
"interactive": {
"type": "product_list",
"header":{
"type": "text",
"text": "header-content"
},
"body": {
"text": "body-content"
},
"footer": {
"text": "footer-content"
},
"action": {
"catalog_id": "CATALOG_ID",
"sections": [
{
"title": "section-title",
"product_items": [
{ "product_retailer_id": "product-SKU-in-catalog" },
{ "product_retailer_id": "product-SKU-in-catalog" },
...
]
},
{
"title": "section-title",
"product_items": [
{ "product_retailer_id": "product-SKU-in-catalog" },
{ "product_retailer_id": "product-SKU-in-catalog" },
...
]
}
]
}
}
}
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "interactive",
"interactive" : {
"type" : "catalog_message",
"body" : {
"text": "Thanks for your order! Tell us what address you’d like this order delivered to."
},
"action": {
"name": "catalog_message",
"parameters": {
"thumbnail_product_retailer_id": "<Product-retailer-id>"
}
}
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "interactive",
"interactive" : {
"type": "flow",
"header": {
"type": "text",
"text": "Flow message header"
},
"body": {
"text": "Flow message body"
},
"footer": {
"text": "Flow message footer"
},
"action": {
"name": "flow",
"parameters": {
"flow_message_version": "3",
"flow_token": "AQAAAAACS5FpgQ_cAAAAAD0QI3s",
"flow_id": "<FLOW_ID>",
"flow_cta": "Book!",
"flow_action": "navigate",
"flow_action_payload": {
"screen": "<SCREEN_ID>",
"data": {
"user_name": "name",
"user_age": 25
}
}
}
}
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "interactive",
"interactive": {
"type": "list",
"header": {
"type": "text",
"text": "HEADER_TEXT"
},
"body": {
"text": "BODY_TEXT"
},
"footer": {
"text": "FOOTER_TEXT"
},
"action": {
"button": "BUTTON_TEXT",
"sections": [
{
"title": "SECTION_1_TITLE",
"rows": [
{
"id": "SECTION_1_ROW_1_ID",
"title": "SECTION_1_ROW_1_TITLE",
"description": "SECTION_1_ROW_1_DESCRIPTION"
},
{
"id": "SECTION_1_ROW_2_ID",
"title": "SECTION_1_ROW_2_TITLE",
"description": "SECTION_1_ROW_2_DESCRIPTION"
}
]
},
{
"title": "SECTION_2_TITLE",
"rows": [
{
"id": "SECTION_2_ROW_1_ID",
"title": "SECTION_2_ROW_1_TITLE",
"description": "SECTION_2_ROW_1_DESCRIPTION"
},
{
"id": "SECTION_2_ROW_2_ID",
"title": "SECTION_2_ROW_2_TITLE",
"description": "SECTION_2_ROW_2_DESCRIPTION"
}
]
}
]
}
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "interactive",
"interactive": {
"type": "button",
"body": {
"text": "BUTTON_TEXT"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "UNIQUE_BUTTON_ID_1",
"title": "BUTTON_TITLE_1"
}
},
{
"type": "reply",
"reply": {
"id": "UNIQUE_BUTTON_ID_2",
"title": "BUTTON_TITLE_2"
}
}
]
}
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "interactive",
"interactive": {
"type": "form_message",
"header": {
"type": "text",
"text": "Rate your experience?",
"sub_text": "Select star to rate your experience"
},
"parameters": {
"version": "1",
"layout": [
{
"type": "Rating",
"rating_type": "STAR_RATING",
"id": "rating-id-1"
}
]
},
"action": {
"name": "form_message"
}
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "template",
"template": {
"name": "TEMPLATE_NAME",
"language": {
"code": "LANGUAGE_AND_LOCALE_CODE"
},
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"link": "http(s)://URL"
}
}
]
},
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "TEXT_STRING"
},
{
"type": "currency",
"currency": {
"fallback_value": "VALUE",
"code": "USD",
"amount_1000": NUMBER
}
},
{
"type": "date_time",
"date_time": {
"fallback_value": "MONTH DAY, YEAR"
}
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "PAYLOAD"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "1",
"parameters": [
{
"type": "payload",
"payload": "PAYLOAD"
}
]
}
]
}
}'
curl -X POST \
'https://graph.facebook.com/v21.0
/FROM_PHONE_NUMBER/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"context": {
"message_id": "MESSAGE_ID"
},
"to": "PHONE_NUMBER",
"type": "text",
"text": {
"preview_url": false,
"body": "your-text-message-content"
}
}’
{ "messaging_product": "whatsapp", "contacts": [ { "input": "16505555555", "wa_id": "16505555555" } ], "messages": [ { "id": "wamid.HBgLMTY1MDUwNzY1MjAVAgARGBI5QTNDQTVCM0Q0Q0Q2RTY3RTcA" } ] }
Applies to businesses in Brazil, Colombia, and Singapore, starting September 12, 2023. Applies to all businesses starting October 12, 2023.
Messages will have one of the following statuses which will be returned in each of the messages
objects
"message_status":"accepted"
: means the message was sent to the intended recipient"message_status":"held_for_quality_assessment"
: means the message send was delayed until quality can be validated and it will either be sent or dropped at this point{ "messaging_product": "whatsapp", "contacts": [ { "input": "16505555555", "wa_id": "16505555555" } ], "messages": [ { "id": "wamid.HBgLMTY1MDUwNzY1MjAVAgARGBI5QTNDQTVCM0Q0Q0Q2RTY3RTcA", "message_status": "accepted", } ] }