SendGridのWebAPIでメールを送信した時にWebhookとの照合用IDを取得する

やりたいこと

SendGridのWebAPIコール時に、あとから送信結果照合するためのIDを取得する。
取得したIDの使い方は別記事で。

tminami.hatenablog.com

APIコール時のレスポンスヘッダー

Server: nginx
Date: Tue, 31 Jul 2018 12:31:58 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Connection: close
X-Message-Id: HOge_UnHmSNCCgV9PeqHuGa
Access-Control-Allow-Origin: https://sendgrid.api-docs.io
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: Authorization, Content-Type, On-behalf-of, x-sg-elas-acl
Access-Control-Max-Age: 600
X-No-CORS-Reason: https://sendgrid.com/docs/Classroom/Basics/API/cors.html

この中の『X-Message-Id』をDBに保持しておく。