API 参考

快速开始

发送图片和文件

先检查渠道能力,准备可访问的媒体 URL,并选择支持的消息类型。

上手步骤

  1. 1

    调用前准备

    先检查渠道能力,准备可访问的媒体 URL,并选择支持的消息类型。

    统一消息发送能力
  2. 2

    参数从哪里取得

    回复消息时,将 message.received 中的 data.conversation.id 和 data.conversation.type 分别复制到 to.id、to.type。发送给新收件方时遵循对应渠道的标识规则。

    发送文本消息
  3. 3

    发送媒体消息

    先检查渠道能力,准备可访问的媒体 URL,并选择支持的消息类型。

    curl -X POST "https://api.unifyport.ai/v1/messages" \
      -H "X-Api-Key: <YOUR_API_KEY>" \
      -H "Content-Type: application/json" \
      -d '{
      "account_id": "acc_example",
      "to": {
        "id": "user_example",
        "type": "user"
      },
      "message": {
        "type": "video",
        "url": "https://cdn.example.com/video/demo.mp4",
        "caption": "hello video"
      },
      "provider_data": {
        "seconds": 12
      }
    }'
    发送媒体消息
  4. 4

    如何理解结果

    保存返回的 message_id 和 provider_ref,用于关联后续事件或排查。accepted 不表示已送达;仅在渠道支持回执时,通过对应事件确认送达。标识格式因渠道而异。

    Webhook 投递与签名校验