[{"email":"john.doe@sendgrid.com","timestamp":1337197600,"smtp-id":"<4FB4041F.6080505@sendgrid.com>","sg_event_id":"sendgrid_internal_event_id","sg_message_id":"sendgrid_internal_message_id","event":"processed"},{"email":"john.doe@sendgrid.com","timestamp":1337966815,"ip":"X.XX.XXX.XX","sg_event_id":"sendgrid_internal_event_id","url":"https://sendgrid.com","sg_message_id":"sendgrid_internal_message_id","useragent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36","event":"click"},{"ip":"X.XX.XXX.XX","sg_user_id":123,"sg_event_id":"sendgrid_internal_event_id","sg_message_id":"sendgrid_internal_message_id","useragent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36","event":"group_unsubscribe","email":"john.doe@sendgrid.com","timestamp":1337969592,"asm_group_id":42}]
ユニーク引数とカスタム引数の機能は同じです:ユニーク引数はSMTP APIまたはv2 Mail Sendでメール送信時に使用される一方、カスタム引数はv3 Mail Sendでメール送信時に使用されます。
ユニーク引数
SMTP APIまたはv2 Mail Sendエンドポイント経由でメール送信時にユニーク引数を受け取りたい場合は、X-SMTPAPIヘッダ(またはパラメータ)でunique_argsパラメータを使用してください。例えば、useridやメールのtemplateといったパラメータをアプリケーションで受信したい場合、こちらに記載された方法でX-SMTPAPIヘッダ(またはパラメータ)内で指定してください。
例えば、v2 Mail Sendエンドポイントでメール送信時にx-smtpapiパラメータに以下のようなユニーク引数を指定した場合:
//for this example, assume we're sending to john.doe@sendgrid.com{"unique_args":{"customerAccountNumber":"55555","activationAttempt":"1","New Argument 1":"New Value 1","email":"jane.doe@sendgrid.com","event":"SendEmail"}}
Webhookの要求
12345678910
[{"event":"Processed","timestamp":"123456789","customerAccountNumber":"55555","activationAttempt":"1","New Argument 1":"New Value 1","email":"john.doe@sendgrid.com"}]
{"status":"5.0.0","sg_event_id":"sendgrid_internal_event_id","sg_message_id":"sendgrid_internal_message_id","event":"bounce","email":"email@example.com","timestamp":1249948800,"smtp-id":"<original-smtp-id@domain.com>","unique_arg_key":"unique_arg_value","category":["category1","category2"],"reason":"500 No Such User","type":"bounce","asm_group_id":1}
<?php$myFile="tmp/log.txt";$fh=fopen($myFile,'a+')ordie("can't open file");if($fh){$headers=apache_request_headers();$postdata=file_get_contents("php://input");foreach($headersas$header=>$value){fwrite($fh,print_r("$header: $value\n",true));}fwrite($fh,print_r("$postdata\n",true));fclose($fh);}echo"ok";?>
{"status":"5.0.0","sg_event_id":"sendgrid_internal_event_id","sg_message_id":"sendgrid_internal_message_id","bounce_classification":"invalid","event":"bounce","email":"email@example.com","timestamp":1249948800,"smtp-id":"<original-smtp-id@domain.com>","unique_arg_key":"unique_arg_value","category":["category1","category2"],"asm_group_id":1,"reason":"500 No Such User","type":"bounce","ip":"127.0.0.1","tls":"1"}
{"sg_event_id":"sendgrid_internal_event_id","sg_message_id":"sendgrid_internal_message_id","ip":"255.255.255.255","useragent":"Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53","event":"click","email":"email@example.com","timestamp":1249948800,"url":"http://yourdomain.com/blog/news.html","url_offset":{"index":0,"type":"html"},"unique_arg_key":"unique_arg_value","category":["category1","category2"],"asm_group_id":1}
{"sg_message_id":"sendgrid_internal_message_id","email":"email@example.com","timestamp":1249948800,"unique_arg_key":"unique_arg_value","category":["category1","category2"],"event":"group_unsubscribe","asm_group_id":1,"useragent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36","ip":"255.255.255.255"}
Group Resubscribe
event
email
asm_group_id
category
group_resubscribe
メッセージの宛先
配信再開するよう設定変更されたASMグループのID
設定したカテゴリ
1234567891011
{"sg_message_id":"sendgrid_internal_message_id","email":"email@example.com","timestamp":1249948800,"unique_arg_key":"unique_arg_value","category":["category1","category2"],"event":"group_resubscribe","asm_group_id":1,"useragent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36","ip":"255.255.255.255"}
{"category":[],"email":"tadpole_0001@stbase-018.sjc1.sendgrid.net","event":"delivered","marketing_campaign_id":23314,"marketing_campaign_name":"unique args ab","post_type":"event","response":"250 Ok ","sg_event_id":"X2M1IUfMRhuAhWM0CbmFqQ","sg_message_id":"fPJrJPIRTxC_obpgfTy74w.stfilter-015.5185.55F883564.0","sg_user_id":12345,"smtp-id":"","timestamp":1442349911}
配信停止された場合のイベントデータの例:
マーケティングキャンペーン機能を通じて送信された場合、配信停止イベントは次のようになります。
123456789101112131415161718
[{"email":"email@example.com","event":"unsubscribe","marketing_campaign_id":12345,"marketing_campaign_name":"campaign name","sg_event_id":"sendgrid_internal_event_id","sg_message_id":"sendgrid_internal_message_id","sg_user_id":12345,"category":["Tests","Newsletter"],"timestamp":1612345670,"useragent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36","ip":"255.255.255.255"}]