Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update signed webhook usage documentation #440

Merged
merged 1 commit into from Oct 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions TROUBLESHOOTING.md
Expand Up @@ -14,6 +14,7 @@ If you can't find a solution below, please open an [issue](https://github.com/se
* [Versions](#versions)
* [Environment Variables and Your Twilio SendGrid API Key](#environment)
* [Viewing the Request Body](#request-body)
* [Verifying Event Webhooks](#signed-webhooks)

<a name="migrating"></a>
## Migrating from v2 to v3
Expand Down Expand Up @@ -108,3 +109,14 @@ You can do this right before you call `response, err := client.Send(message)` li
```go
fmt.Println(string(mail.GetRequestBody(message)))
```

<a name="signed-webhooks"></a>
## Signed Webhook Verification

Twilio SendGrid's Event Webhook will notify a URL via HTTP POST with information about events that occur as your mail is processed. [This](https://docs.sendgrid.com/for-developers/tracking-events/getting-started-event-webhook-security-features) article covers all you need to know to secure the Event Webhook, allowing you to verify that incoming requests originate from Twilio SendGrid. The sendgrid-go library can help you verify these Signed Event Webhooks.

You can find the end-to-end usage example [here](helpers/eventwebhook/README.md) and the tests [here](helpers/eventwebhook/eventwebhook_test.go).
If you are still having trouble getting the validation to work, follow the following instructions:
- Be sure to use the *raw* payload for validation
- Be sure to include a trailing carriage return and newline in your payload
- In case of multi-event webhooks, make sure you include the trailing newline and carriage return after *each* event