v2.25.4
以降、メディアメッセージテンプレートが拡張され、標準メッセージテンプレートタイプ以上のコンテンツを受信者に送ることができるようになりました。components
オブジェクトを使用して、メディア、ヘッダー、フッターを含めることができます。components
オブジェクトを使うと、メッセージのtype
や、メッセージのparameters
パラメーターを指定できます。
POST /v1/messages { "to": "recipient_wa_id", "ttl": "P4D" | "3600" | 3600, "type": "template", "template": { "namespace": "your-namespace", "language": { "policy": "deterministic", "code": "your-language-and-locale-code" }, "name": "your-template-name", "components": [ { "type" : "header", "parameters": [ # The following parameters code example includes several different possible header types, # not all are required for a media message template API call. { "type": "text", "text": "replacement_text" } # OR { "type": "document", "document": { "id": "your-media-id", # filename is an optional parameter "filename": "your-document-filename" } } # OR { "type": "document", "document": { "link": "the-provider-name/protocol://the-url", # provider and filename are optional parameters "provider": { "name" : "provider-name" }, "filename": "your-document-filename" } } # OR { "type": "image", "image": { "link": "http(s)://the-url", # provider is an optional parameter "provider": { "name" : "provider-name" }, } } ] # end header }, { "type" : "body", "parameters": [ { "type": "text", "text": "replacement_text" }, { "type": "currency", "currency" : { "fallback_value": "$100.99", "code": "USD", "amount_1000": 100990 } }, { "type": "date_time", "date_time" : { "fallback_value": "February 25, 1977", "day_of_week": 5, "day_of_month": 25, "year": 1977, "month": 2, "hour": 15, "minute": 33, #OR "timestamp": 1485470276 } }, { ... # Any additional template parameters } ] # end body }, ] } }
名前 | 必須かどうか | 説明 |
---|---|---|
| 必須 | 受信者のWhatsApp ID |
| 任意 | TTL (有効生存期間) |
| 任意 | メディアテンプレートメッセージを送信するため |
| 必須( | すべてのテンプレート情報を含む |
template
オブジェクト名前 | 必須かどうか | 説明 |
---|---|---|
| 必須 | テンプレートの名前空間 |
| 必須 | テンプレートの名前 |
| 必須 | テンプレートがレンダリングされる言語を指定します。 |
| 任意 | メッセージのパラメーターを含んだ配列 |
components
オブジェクト名前 | 必須かどうか | 説明 |
---|---|---|
| 必須 |
|
| 任意 | メッセージのコンテンツを含んだ配列 |
parameters
オブジェクト名前 | 必須かどうか | 説明 |
---|---|---|
| 必須 |
|
成功した場合の応答には、id
を持つmessages
オブジェクトが含まれます。
{ "messages": [{ "id": "gBEGkYiEB1VXAglK1ZEqA1YKPrU" }] }
失敗した場合の応答には、エラー文字列、エラーコード、その他の情報を含むエラーオブジェクトが含まれます。
テンプレートを受信できないアカウントにテンプレートが送信された場合、構成済みのWebhookサーバーに、エラーオブジェクトとして1026 (ReceiverIncapable)
エラーが送信されます。
エラーについて詳しくは、エラーおよびステータスコードをご覧ください。