你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Notification Messages Operations - Send

将通知消息从企业发送到用户。

POST {endpoint}/messages/notifications:send?api-version=2024-02-01

URI 参数

名称 必需 类型 说明
endpoint
path True

string

uri

通信资源,例如 https://my-resource.communication.azure.com

api-version
query True

string

用于此操作的 API 版本。

请求头

名称 必需 类型 说明
Repeatability-Request-ID

string

请求的不透明、全局唯一的客户端生成的字符串标识符。

Repeatability-First-Sent

string

date-time

指定首次创建请求的日期和时间。

x-ms-client-request-id

string

uuid

请求的不透明、全局唯一的客户端生成的字符串标识符。

请求正文

请求正文可以为下列任一内容:

名称 说明
MediaNotificationContent

发送图像通知的请求。

TemplateNotificationContent

发送模板通知的请求。

TextNotificationContent

发送文本通知的请求。

MediaNotificationContent

发送图像通知的请求。

名称 必需 类型 说明
channelRegistrationId True

string

业务标识符的通道注册 ID。

kind True string:

image

描述通知类型的类型鉴别器。

mediaUri True

string

文件的媒体 URL。 如果类型是受支持的媒体类型之一,则为必需类型,例如图像

to True

string[]

收件人的本机外部平台用户标识符。

content

string

可选文本内容。

TemplateNotificationContent

发送模板通知的请求。

名称 必需 类型 说明
channelRegistrationId True

string

业务标识符的通道注册 ID。

kind True string:

template

描述通知类型的类型鉴别器。

template True

MessageTemplate

用于创建模板的模板对象。

to True

string[]

收件人的本机外部平台用户标识符。

TextNotificationContent

发送文本通知的请求。

名称 必需 类型 说明
channelRegistrationId True

string

业务标识符的通道注册 ID。

content True

string

消息内容。

kind True string:

text

描述通知类型的类型鉴别器。

to True

string[]

收件人的本机外部平台用户标识符。

响应

名称 类型 说明
202 Accepted

SendMessageResult

已接受请求进行处理,但尚未完成处理。

标头

  • Repeatability-Result: string
  • x-ms-client-request-id: string
Other Status Codes

Azure.Core.Foundations.ErrorResponse

意外的错误响应。

标头

x-ms-error-code: string

安全性

AadOauth2Auth

Azure Active Directory OAuth2 流

类型: oauth2
流向: accessCode
授权 URL: https://login.microsoftonline.com/common/oauth2/authorize
令牌 URL: https://login.microsoftonline.com/common/oauth2/token

作用域

名称 说明
https://communication.azure.com/.default

Authorization

类型: apiKey
在: header

示例

Sends a notification message - image
Sends a notification message - Template
Sends a notification message - text

Sends a notification message - image

示例请求

POST https://my-resource.communication.azure.com/messages/notifications:send?api-version=2024-02-01

{
  "channelRegistrationId": "0f0eb78e-a576-1dfc-b414-0f0756de3338",
  "to": [
    "14250000000"
  ],
  "kind": "image",
  "mediaUri": "https://example.com/image.jpg",
  "content": "check out this image!"
}

示例响应

{
  "receipts": [
    {
      "messageId": "320fc2a1-4c4b-4387-9c1a-bd38b57795de",
      "to": "14250000000"
    }
  ]
}

Sends a notification message - Template

示例请求

POST https://my-resource.communication.azure.com/messages/notifications:send?api-version=2024-02-01

{
  "channelRegistrationId": "0f0eb78e-a576-1dfc-b414-0f0756de3338",
  "to": [
    "14250000000"
  ],
  "kind": "template",
  "template": {
    "name": "example",
    "language": "en",
    "values": [
      {
        "name": "userName",
        "kind": "text",
        "text": "John Doe"
      },
      {
        "name": "orderNumber",
        "kind": "text",
        "text": "12345"
      }
    ],
    "bindings": {
      "body": [
        {
          "refValue": "userName"
        },
        {
          "refValue": "orderNumber"
        }
      ],
      "kind": "whatsApp"
    }
  }
}

示例响应

{
  "receipts": [
    {
      "messageId": "320fc2a1-4c4b-4387-9c1a-bd38b57795de",
      "to": "14250000000"
    }
  ]
}

Sends a notification message - text

示例请求

POST https://my-resource.communication.azure.com/messages/notifications:send?api-version=2024-02-01

{
  "channelRegistrationId": "0f0eb78e-a576-1dfc-b414-0f0756de3338",
  "to": [
    "14250000000"
  ],
  "kind": "text",
  "content": "Text message through CPM"
}

示例响应

{
  "receipts": [
    {
      "messageId": "320fc2a1-4c4b-4387-9c1a-bd38b57795de",
      "to": "14250000000"
    }
  ]
}

定义

名称 说明
Azure.Core.Foundations.Error

错误对象。

Azure.Core.Foundations.ErrorResponse

包含错误详细信息的响应。

Azure.Core.Foundations.InnerError

包含有关错误的更具体信息的对象。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

CommunicationMessageKind

消息的类型。

MediaNotificationContent

发送图像通知的请求。

MessageReceipt

收到发送一条消息。

MessageTemplate

用于创建模板的模板对象。

MessageTemplateBindingsKind

消息模板的类型。

MessageTemplateDocument

消息模板的文档值信息。

MessageTemplateImage

消息模板的图像值信息。

MessageTemplateLocation

消息模板的位置值信息。

MessageTemplateQuickAction

消息模板的快速操作值信息。

MessageTemplateText

消息模板的文本值信息。

MessageTemplateValueKind

模板参数的类型。

MessageTemplateVideo

消息模板的视频值信息。

SendMessageResult

发送消息操作的结果。

TemplateNotificationContent

发送模板通知的请求。

TextNotificationContent

发送文本通知的请求。

WhatsAppMessageButtonSubType

WhatsApp 按钮子类型。

WhatsAppMessageTemplateBindings

WhatsApp 的模板绑定

WhatsAppMessageTemplateBindingsButton

WhatsApp 的模板绑定组件按钮

WhatsAppMessageTemplateBindingsComponent

WhatsApp 的模板绑定组件

Azure.Core.Foundations.Error

错误对象。

名称 类型 说明
code

string

服务器定义的错误代码集之一。

details

Azure.Core.Foundations.Error[]

导致此报告错误的特定错误的详细信息数组。

innererror

Azure.Core.Foundations.InnerError

包含与当前对象有关错误的更具体信息的对象。

message

string

错误的人工可读表示形式。

target

string

错误的目标。

Azure.Core.Foundations.ErrorResponse

包含错误详细信息的响应。

名称 类型 说明
error

Azure.Core.Foundations.Error

错误对象。

Azure.Core.Foundations.InnerError

包含有关错误的更具体信息的对象。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

名称 类型 说明
code

string

服务器定义的错误代码集之一。

innererror

Azure.Core.Foundations.InnerError

内部错误。

CommunicationMessageKind

消息的类型。

名称 类型 说明
image

string

图像消息类型。

template

string

模板消息类型。

text

string

短信类型。

MediaNotificationContent

发送图像通知的请求。

名称 类型 说明
channelRegistrationId

string

业务标识符的通道注册 ID。

content

string

可选文本内容。

kind string:

image

描述通知类型的类型鉴别器。

mediaUri

string

文件的媒体 URL。 如果类型是受支持的媒体类型之一,则为必需类型,例如图像

to

string[]

收件人的本机外部平台用户标识符。

MessageReceipt

收到发送一条消息。

名称 类型 说明
messageId

string

消息 ID。

to

string

收件人的本机外部平台用户标识符。

MessageTemplate

用于创建模板的模板对象。

名称 类型 说明
bindings MessageTemplateBindings:

WhatsAppMessageTemplateBindings

用于将值链接到模板特定位置的绑定对象

language

string

采用 ISO 639 格式的模板语言由双字母语言代码组成,后跟可选的双字母国家/地区代码,例如“en”或“en_US”。

name

string

模板的名称。

values MessageTemplateValue[]:

模板值。

MessageTemplateBindingsKind

消息模板的类型。

名称 类型 说明
whatsApp

string

WhatsApp 模板类型。

MessageTemplateDocument

消息模板的文档值信息。

名称 类型 说明
caption

string

媒体对象的 [可选] 标题。

fileName

string

媒体文件的 [可选] 文件名。

kind string:

document

描述模板参数类型的类型鉴别器。

name

string

模板绑定引用名称

url

string

媒体的(公共)URL。

MessageTemplateImage

消息模板的图像值信息。

名称 类型 说明
caption

string

媒体对象的 [可选] 标题。

fileName

string

媒体文件的 [可选] 文件名。

kind string:

image

描述模板参数类型的类型鉴别器。

name

string

模板绑定引用名称

url

string

媒体的(公共)URL。

MessageTemplateLocation

消息模板的位置值信息。

名称 类型 说明
address

string

位置的 [可选] 地址。

kind string:

location

描述模板参数类型的类型鉴别器。

latitude

number

位置的纬度。

locationName

string

位置的 [可选] 名称。

longitude

number

位置的经度。

name

string

模板绑定引用名称

MessageTemplateQuickAction

消息模板的快速操作值信息。

名称 类型 说明
kind string:

quickAction

描述模板参数类型的类型鉴别器。

name

string

模板绑定引用名称

payload

string

[可选] 快速操作有效负载

text

string

[可选] 快速操作文本

MessageTemplateText

消息模板的文本值信息。

名称 类型 说明
kind string:

text

描述模板参数类型的类型鉴别器。

name

string

模板绑定引用名称

text

string

文本值。

MessageTemplateValueKind

模板参数的类型。

名称 类型 说明
document

string

文档模板参数类型。

image

string

映像模板参数类型。

location

string

位置模板参数类型。

quickAction

string

快速操作模板参数类型。

text

string

文本模板参数类型。

video

string

视频模板参数类型。

MessageTemplateVideo

消息模板的视频值信息。

名称 类型 说明
caption

string

媒体对象的 [可选] 标题。

fileName

string

媒体文件的 [可选] 文件名。

kind string:

video

描述模板参数类型的类型鉴别器。

name

string

模板绑定引用名称

url

string

媒体的(公共)URL。

SendMessageResult

发送消息操作的结果。

名称 类型 说明
receipts

MessageReceipt[]

发送消息操作的收据。

TemplateNotificationContent

发送模板通知的请求。

名称 类型 说明
channelRegistrationId

string

业务标识符的通道注册 ID。

kind string:

template

描述通知类型的类型鉴别器。

template

MessageTemplate

用于创建模板的模板对象。

to

string[]

收件人的本机外部平台用户标识符。

TextNotificationContent

发送文本通知的请求。

名称 类型 说明
channelRegistrationId

string

业务标识符的通道注册 ID。

content

string

消息内容。

kind string:

text

描述通知类型的类型鉴别器。

to

string[]

收件人的本机外部平台用户标识符。

WhatsAppMessageButtonSubType

WhatsApp 按钮子类型。

名称 类型 说明
quickReply

string

WhatsApp 按钮子类型是快速答复。

url

string

WhatsApp 按钮子类型为 URL。

WhatsAppMessageTemplateBindings

WhatsApp 的模板绑定

名称 类型 说明
body

WhatsAppMessageTemplateBindingsComponent[]

正文模板绑定

buttons

WhatsAppMessageTemplateBindingsButton[]

按钮模板绑定

footer

WhatsAppMessageTemplateBindingsComponent[]

页脚模板绑定

header

WhatsAppMessageTemplateBindingsComponent[]

标头模板绑定

kind string:

whatsApp

描述模板绑定类型的类型鉴别器。

WhatsAppMessageTemplateBindingsButton

WhatsApp 的模板绑定组件按钮

名称 类型 说明
refValue

string

模板值中引用的项的名称。

subType

WhatsAppMessageButtonSubType

WhatsApp 按钮子类型

WhatsAppMessageTemplateBindingsComponent

WhatsApp 的模板绑定组件

名称 类型 说明
refValue

string

模板值中引用的项的名称。