Skip to content

メールオブジェクト

email オブジェクトを使用すると、メッセージングエンドポイントを通じてメールを変更または作成できます。

メールオブジェクト

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "app_id": (required, string), see App Identifier,
  "subject": (optional, string),
  "from": (required, valid email address in the format "Display Name <[email protected]>"),
  "reply_to": (optional, valid email address in the format "[email protected]" - defaults to your workspace's default reply to if not set) - use "NO_REPLY_TO" to set reply-to address to null,
  "bcc": (optional, one of the BCC addresses defined in your workspace's email settings) if provided and the BCC feature is enabled for your account, this address gets added to your outbound message as a BCC address,
  "body": (required unless email_template_id is given, valid HTML),
  "plaintext_body": (optional, valid plaintext, defaults to autogenerating plaintext from "body" when this is not set),
  "preheader": (optional*, string) recommended length 50-100 characters,
  "email_template_id": (optional, string) if provided, Braze uses the subject/body/should_inline_css values from the given email template UNLESS they are specified here, in which case Braze overrides the provided template,
  "message_variation_id": (optional, string) used when providing a campaign_id to specify which message variation this message should be tracked under,
  "extras": (optional, valid Key-Value Hash) extra hash - for SendGrid users, this is passed to SendGrid as Unique Arguments,
  "headers": (optional, valid Key-Value Hash) hash of custom extensions headers (available for SparkPost, SendGrid, or Amazon SES),
  "should_inline_css": (optional, boolean) whether to inline CSS on the body. If not provided, falls back to the default CSS inlining value for the workspace,
  "attachments": (optional, array) array of JSON objects that define the files you need attached, defined by "file_name", "url", and optionally "basic_auth_credential",
    "file_name": (required, string) the name of the file you want to attach to your email, excluding the extension (for example, ".pdf"). Attach files up to 2 MB. This is required if you use "attachments",
    "url": (required, string) the corresponding URL of the file you want to attach to your email. The file name's extension is detected automatically from the URL defined, which should return the appropriate "Content-Type" as a response header. This is required if you use "attachments",
    "basic_auth_credential": (optional, string) the name of the stored basic authentication credential to use when the attachment URL requires a login,
}
  • アプリ識別子
    • ワークスペースに設定されたアプリの有効な app_id であれば、そのユーザーのプロファイルにそのアプリがあるかどうかに関係なく、ワークスペース内のすべてのユーザーに対して機能します。
  • プリヘッダーの詳細とベストプラクティスについては、メールのスタイリングを参照してください。

有効な添付ファイルの種類は次のとおりです: txtcsvlogcssicsjpgjpejpeggifpngbmppsdtiftiffsvginddaiepsdocdocxrtfodtottpdfpubpagesmobiepubmp3m4am4vwmaoggflacwavaifaifcaiffmp4movavimkvmpegmpgwmvxlsxlsxodsnumbersodppptpptxppskeyzipvcfpkpass

email_template_id は、HTMLエディターで作成したメールテンプレートの下部から取得できます。以下は、このIDがどのように表示されるかの例です。

HTMLメールテンプレートのAPI識別子セクション。

添付ファイル付きメールオブジェクトの例

1
2
3
4
5
6
7
8
9
10
11
12
{
  "external_user_ids": ["YOUR_EXTERNAL_USER_ID"],
  "messages":{
     "email":{
        "app_id":"YOUR_APP_ID",
        "attachments":[{
            "file_name":"YourFileName",
            "url":"https://exampleurl.com/YourFileName.pdf"
         }]
     }
  }
}

メール添付ファイルの認証

添付ファイルのURLにログインが必要な場合は、保存済みのBasic認証の認証情報を使用します。これは、/messages/sendのメールオブジェクト内の添付ファイル、および/campaigns/trigger/sendのトップレベルのattachments配列に適用されます。

  1. 設定 > Connected Content に移動します。
  2. 認証情報を追加を選択します。
  3. Basic認証を選択します。
  4. 認証情報名、ユーザー名、パスワードを入力します。
  5. 認証が必要な各添付ファイルにbasic_auth_credentialプロパティを含め、その認証情報名に設定します。次の例では、メールオブジェクト内で認証情報名company_basic_auth_credential_nameを使用しています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
  "external_user_ids": ["recipient_user_id"],
  "messages":{
    "email":{
      "app_id": "153e8a29-fd6d-4f77-ade7-1a4ca08d457a",
      "subject": "Basic auth attachment test",
      "from": "mail <[email protected]>",
      "body": "my attachment test",
      "attachments":[
        { "file_name":"checkout_receipt.pdf",
        "url":"https://fileserver.company.com/user123-checkout_receipt.pdf",
        "basic_auth_credential": "company_basic_auth_credential_name" }
      ]
    }
  }
}

添付ファイルの取得、キャッシュ、パフォーマンス

Brazeが添付ファイルのurlからファイルを取得する際の注意事項:

  • キャッシュ: Brazeは最近取得したファイルを約24時間再利用する場合があります。送信のたびに最新バージョンのファイルを確実に取得する必要がある場合は、バージョンごとに異なるURLを使用してください(例: ファイルの変更に応じてパスやクエリを変更するなど)。
  • タイムアウト: ホストは迅速に応答する必要があります。添付ファイルのURLの応答が遅い場合やハングした場合、メッセージの送信が失敗する可能性があります。約2分以内の応答を目指してください。
  • セキュリティ: 添付ファイルのURL(クエリ文字列を含む)に個人を特定できる情報(PII)や機密情報を含めないでください。URLはログや下流のシステムに表示される可能性があります。
  • ファイアウォール: URLが特定のネットワークからのみアクセス可能な場合は、Connected Content IP許可リストに従ってBrazeからのトラフィックを許可してください。ファイルにログインが必要な場合は、ベーシック認証の認証情報を使用してください。
New Stuff!