Skip to content

API トリガー配信を使用したキャンペーンメッセージの送信

post

/campaigns/trigger/send

このエンドポイントを使用して、API トリガー配信を介して、指定されたユーザに即時のワンオフメッセージを送信します。

API トリガー配信では、メッセージが送信されたとき、およびAPI 経由で誰に送信されるかを指示しながら、Braze ダッシュボード内にメッセージコンテンツを保存できます。

セグメントをターゲットとしている場合、リクエストのレコードはDeveloper Console に保存されます。このエンドポイントでメッセージを送信するには、キャンペーンID を作成し、API トリガキャンペーン を作成する必要があります。

前提条件

このエンドポイントを使用するには、campaigns.trigger.send 権限を持つAPI キーを生成する必要があります。

レート制限

When specifying a segment or Connected Audience in your request, we apply a rate limit of 250 requests per minute to this endpoint. Otherwise, if specifying an external_id, this endpoint has a default rate limit of 250,000 requests per hour shared between /messages/send, /campaigns/trigger/send, and /canvas/trigger/send, as documented in API rate limits.

Braze endpoints support batching API requests. A single request to the messaging endpoints can reach any of the following:

  • Up to 50 specific external_ids, each with individual message parameters
  • A segment of any size created in the Braze dashboard, specified by its segment_id
  • An audience segment of any size, defined in the request as a connected audience object

リクエスト本文

1
2
Content-Type: application/json
Authorization: Bearer YOUR-REST-API-KEY
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "campaign_id": (required, string) see campaign identifier,
  "send_id": (optional, string) see send identifier,
  "trigger_properties": (optional, object) personalization key-value pairs that will apply to all users in this request,
  "broadcast": (optional, boolean) see broadcast -- defaults to false on 8/31/17, must be set to true if "recipients" is omitted,
  "audience": (optional, connected audience object) see connected audience,
  // Including 'audience' will only send to users in the audience
  "recipients": (optional, array; if not provided and broadcast is not set to `false`, message will send to the entire segment targeted by the campaign)
    [
      {
      // Either "external_user_id" or "user_alias" is required. Requests must specify only one.
      "user_alias": (optional, user alias object) user alias of user to receive message,
      "external_user_id": (optional, string) external identifier of user to receive message,
      "trigger_properties": (optional, object) personalization key-value pairs that will apply to this user (these key-value pairs will override any keys that conflict with the parent trigger_properties),
      "send_to_existing_only": (optional, boolean) defaults to true, can't be used with user aliases; if set to `false`, an attributes object must also be included,
      "attributes": (optional, object) fields in the attributes object will create or update an attribute of that name with the given value on the specified user profile before the message is sent and existing values will be overwritten
    }
  ]
}

要求パラメータ

パラメータ 必須 データ型 説明  
campaign_id 必須 文字列 参照キャンペーン識別子.  
send_id オプション 文字列 送信識別子を参照  
trigger_properties オプション オブジェクト トリガプロパティを参照してください。この要求のすべてのユーザーに適用されるカスタマイズキーと値のペア。  
  broadcast オプション ブール キャンペーンまたはキャンバスがターゲットとするセグメント全体にメッセージを送信するときは、broadcast をtrue に設定する必要があります。このパラメーターのデフォルトはfalse です(2017年8 月31 日現在)。

broadcast がtrue に設定されている場合、recipients リストを含めることはできません。ただし、broadcast: true を設定するときは注意が必要です。意図せずにこのフラグを設定すると、期待した視聴者よりも大きな視聴者にメッセージが送信される可能性があります。
audience オプション 接続されたオーディエンスオブジェクト 接続されたオーディエンスを参照  
recipients オプション 配列 recipients objectを参照してください。

send_to_existing_onlyfalse の場合、属性オブジェクトを含める必要があります。

recipients が指定されず、broadcast がtrue に設定されている場合、メッセージはキャンペーンの対象となるセグメント全体に送信されます。
 
  • recipients 配列には、最大50 個のオブジェクトを含めることができます。各オブジェクトには、単一のexternal_user_id 文字列とtrigger_properties オブジェクトが含まれます。
  • send_to_existing_onlytrue の場合、Braze はメッセージを既存のユーザにのみ送信します。ただし、このフラグはユーザーエイリアスでは使用できません。
  • send_to_existing_onlyfalse の場合、属性を含める必要があります。Braze は、id と属性を持つユーザを作成してからメッセージを送信します。

ユーザのサブスクリプショングループのステータスは、subscription_groups パラメータをattributes オブジェクトに含めることで更新できます。詳細については、ユーザー属性オブジェクトを参照してください。

リクエスト例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
curl --location --request POST 'https://rest.iad-01.braze.com/campaigns/trigger/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR-REST-API-KEY' \
--data-raw '{
  "campaign_id": "campaign_identifier",
  "send_id": "send_identifier",
  "trigger_properties": "",
  "broadcast": false,
  "audience": {
    "AND": [
      {
        "custom_attribute": {
          "custom_attribute_name": "eye_color",
          "comparison": "equals",
          "value": "blue"
        }
      },
      {
        "custom_attribute": {
          "custom_attribute_name": "favorite_foods",
          "comparison": "includes_value",
          "value": "pizza"
        }
      },
      {
        "OR": [
          {
            "custom_attribute": {
              "custom_attribute_name": "last_purchase_time",
              "comparison": "less_than_x_days_ago",
              "value": 2
            }
          },
          {
            "push_subscription_status": {
              "comparison": "is",
              "value": "opted_in"
            }
          }
        ]
      },
      {
        "email_subscription_status": {
          "comparison": "is_not",
          "value": "subscribed"
        }
      },
      {
        "last_used_app": {
          "comparison": "after",
          "value": "2019-07-22T13:17:55+0000"
        }
      }
    ]
  },
  "recipients": [
    {
      "user_alias": {
        "alias_name" : "example_name",
        "alias_label" : "example_label"
      },
      "external_user_id": "external_user_identifier",
      "trigger_properties": "",
      "send_to_existing_only": true,
      "attributes": {
        "first_name" : "Alex"
      }
    }
  ]
}'

対応内容

メッセージ送信エンドポイント応答には、メッセージのディスパッチへの参照のためのメッセージのdispatch_id が含まれます。dispatch_id はメッセージディスパッチのID で、Braze から送信される各送信の一意のID です。このエンドポイントを使用すると、バッチ処理されたユーザーのセット全体に対して単一のdispatch_id を受け取ります。dispatch_id の詳細については、 Dispatch ID behavior のドキュメントを参照してください。

送信エンドポイントの作成

キャンペーンでの属性オブジェクトの使用

Braze には、attributes というメッセージングオブジェクトがあり、API トリガキャンペーンを送信する前に、ユーザの属性と値を追加、作成、または更新できます。このAPI コールとしてcampaign/trigger/send エンドポイントを使用すると、ユーザー属性オブジェクトが処理され、キャンペーンが送信される前に処理されます。これにより、race conditionsに起因する問題が発生するリスクを最小限に抑えることができます。

「このページはどの程度役に立ちましたか?」
New Stuff!