- 默认分类
- Registration
- Application
- Certificates
- Contacts
- Groups
- Health
- Media
- Messages
- Two-Step Verification
- Backup/Restore
- Business Profile
- Backup
- Profile
- Users
Send-Message
POST
/messages
Messages
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location -g --request POST 'http:///messages' \
--header 'Content-Type: application/json' \
--data-raw '{
"recipient_type": "individual",
"text": {
"body": "<Message Text>"
},
"to": "{{Recipient-WA-ID}}",
"type": "text"
}'
响应示例响应示例
{
"messages": [
{
"id": "gBEGkYiEB1VXAglK1ZEqA1YKPrU"
}
],
"errors": [
{
"code": 1234,
"details": "optional-detailed-error-message",
"title": "error-code-title"
}
],
"meta": {
"api_status": "deprecated",
"version": "whatsapp-business-api-client-version"
}
}
请求参数
Body 参数application/json
audio
Audio
One of
示例值:
{"id":"<Media Id, from Media API>"}
id
string
必需
contacts
array[object (Contact) {8}]
可选
addresses
array[object (Address) {7}]
可选
birthday
string
可选
emails
array[object (Email) {2}]
可选
ims
array[string]
可选
name
object (Name)
可选
示例值:
{"first_name":"John","formatted_name":"John Smith","last_name":"Smith"}
org
object (Org)
可选
示例值:
{"company":"WhatsApp","department":"Design","title":"Manager"}
phones
array[object (Phone) {3}]
可选
urls
array[object (Root Type for Url) {2}]
可选
document
Document
One of
示例值:
{"caption":"<Message Caption>","filename":"<Filename>","id":"<Media Id, from Media API>"}
caption
string
必需
filename
string
必需
id
string
必需
hsm
object (Hsm)
可选
示例值:
{"element_name":"hello_world","language":{"code":"en","policy":"deterministic"},"localizable_params":[{"default":"1234"}],"namespace":"business_a_namespace"}
element_name
string
必需
language
object (Language)
必需
示例值:
{"code":"en","policy":"deterministic"}
localizable_params
array[object (LocalizableParam) {3}]
必需
namespace
string
必需
image
Image
One of
示例值:
{"caption":"<Message Caption>","id":"<Media Id, from Media API>"}
caption
string
必需
id
string
必需
location
object (Location)
可选
示例值:
{"address":"<Location's Address>","latitude":"<Latitude>","longitude":"<Longitude>","name":"<Location Name>"}
address
string
必需
latitude
string
必需
longitude
string
必需
name
string
必需
preview_url
boolean
可选
To include a URL preview, set preview_url to true in the message body and make sure the URL begins with http:// or https://. For more information, see the Sending URLs in Text Messages section.
recipient_type
enum<string>
可选
Specifying recipient_type in the request is optional when the value is individual.
However, recipient_type is required when using group. If sending a text message to a group, see the Sending Group Messages documentation.
枚举值:
individualgroup
默认值:
individual
text
object (Text)
可选
示例值:
{"body":"<Message Text>"}
body
string
必需
to
string
必需
ttl
object
可选
type
enum<string>
可选
枚举值:
audiocontactsdocumenthsmimagelocationtextvideovoiceunknown
默认值:
text
video
Video
One of
示例值:
{"caption":"<Message Caption>","id":"<Media Id, from Media API>"}
caption
string
必需
id
string
必需
示例
返回响应
🟢200成功
application/json
Body
errors
array[object (Error) {4}]
可选
code
integer <int32>
可选
details
string
可选
href
string
可选
title
string
可选
meta
object
Meta
示例值:
{"api_status":"stable","version":"whatsapp-business-api-client-version"}
api_status
enum<string>
可选
枚举值:
deprecatedexperimentalstable
version
string
可选
messages
array[object (Message) {1}]
可选
id
string
可选
修改于 2024-09-24 06:57:26