0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SendGridでサブユーザーを使ってWebhookの行き先を環境で分ける ✉️

0
Last updated at Posted at 2025-12-25

今回紹介する方法はProプラン以降で使用可能のものです💰
Proプランを使用している想定での話となります🙏

結論
同じSendGridアカウントのままでWebhookの行き先(開発環境/本番環境)を分けるにはサブユーザーが必要です
https://sendgrid.kke.co.jp/docs/User_Manual_JP/Settings/Subusers/index.html

完走賞に全く届かなかったアドベントカレンダーです🗓️

背景 ✉️

同じアカウントでWebhookの行き先を開発環境と本番環境に指定していたため、開発環境でのイベントによって、本番環境にsendgridからAPIコールが稀に起きてしまっていました。

custom_argsにenvを渡すことでも対応できますが、sendgrid側の設定でwebhookの行き先を開発と本番で分離する方法を考えます。

今回は同じSendGridアカウントのままのままでWebhookの行き先を分けたいです。
理由は、別アカウントを作ると運用に負荷がかかるためです。

  • ログイン/2FA/メンバー招待、監査、棚卸し、請求等

sendgridはアカウントの下にチームメートがあります。
同じアカウントに対して、複数人をチームメートとして招待して共有できます。
デフォルトのアカウントは「My SendGrid Account」という名前です。
https://sendgrid.kke.co.jp/docs/User_Manual_JP/Settings/teammates.html

同じSendGridアカウントでWebhookの行き先を環境で分ける手順 💡

  1. サブユーザーを一つ作成する(開発環境用)
    https://sendgrid.kke.co.jp/docs/User_Manual_JP/Settings/Subusers/index.html
    今動いているアカウント(親アカウント)は本番送信用として使い続ける

  2. サブユーザーでEvent Webhookを設定をする

サブユーザーについて

proプランは設定できるwebhookがmax5件です
https://sendgrid.com/en-us/pricing

事故を防ぐため以下の案は不採用にしました。

サブユーザーを2つ(本番/開発)作る案
親を管理専用にする

  • メリット
    • 権限やキーの棚卸しが明確
    • 将来さらに環境が増えても拡張しやすい
  • デメリット
    • 移行手順が増える(本番送信元のキーも差し替える必要がある)
    • 事故が起きる可能性

参考 📚

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?