API 參考
訊息POST

發送文字訊息

透過指定嘅渠道帳號發送一則標準化嘅文字訊息。provider_data 可以承載 reply_to、parse_mode 等渠道專屬欄位。

https://api.unifyport.ai/v1/messages

請求標頭

X-Api-Key
string必填

工作區 API Key,工作區會由呢個標頭解析得出嚟。

Content-Type
string必填

發送 JSON 請求內容嘅時候請用 application/json。

路徑參數

呢個介面冇路徑參數。

請求內容

account_id
string必填

發送呢條訊息嘅渠道帳號。

to
object必填

收件方目標,包括 id 同 type。

message
object必填

標準化嘅訊息內容:文字用 message.text,媒體用 message.url。

provider_data
object

渠道專屬嘅選項,例如 reply_to、parse_mode。

回應內容

message_id
string

已受理訊息嘅 UnifyPort 訊息識別碼(msg_...)。

account_id
string

呢個回應所指嘅渠道帳號。

status
string

受理狀態;accepted 即係訊息已經排隊等住派去渠道。

provider_ref
string

渠道側嘅訊息參考,等渠道編咗號之後先會有。

回應

200
200 OK

請求成功,回應內容嘅例子如上。

400
請求錯誤

請求內容、路徑或者參數無效。

401
未授權

X-Api-Key 請求標頭缺少或者無效。

409
衝突

目前操作同現有嘅渠道帳號或者資源衝突。

500
伺服器錯誤

服務遇到咗未預期嘅錯誤。

請求

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": "text",
    "text": "Hello from UnifyPort"
  },
  "provider_data": {
    "parse_mode": "markdown"
  }
}'

回應

{
  "data": {
    "message_id": "msg_example",
    "account_id": "acc_example",
    "status": "accepted",
    "provider_ref": "provider_msg_example"
  }
}