Skip to content

Commit

Permalink
Added a section on "Developing and Testing Webhooks" in existing page (
Browse files Browse the repository at this point in the history
…#7456)

* Added a section on "Developing and Testing Webhooks" in existing page

* Apply suggestions from code review

Co-authored-by: Liza Mock <[email protected]>

* lint

---------

Co-authored-by: Liza Mock <[email protected]>
Co-authored-by: Shana Matthews <[email protected]>
  • Loading branch information
3 people authored Jul 24, 2023
1 parent 79904c8 commit fd20673
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/docs/product/integrations/integration-platform/webhooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ We've built an [example application](https://github.com/getsentry/integration-pl

</Note>

Webhooks allow your service to receive requests about specific resources, depending on your selection, such as installation, issues, and alerts:
Webhooks are a way for two applications or services to communicate over the web, allowing one application to send automatic notifications or data updates to another in near real-time.

The concept is based on HTTP callbacks, where an HTTP POST request is sent to a specific URL (an HTTP endpoint in your tech stack) with a payload. Sentry uses JSON webhooks to get error notifications to your systems or services.

![Sentry integration webhook checkbox](webhook-checkbox.png)

## Headers

All webhooks will contain the following set of request headers:
Sentry webhooks support various functionalities and are made up of four integral HTTP headers described below:

```json
{
Expand All @@ -30,11 +32,11 @@ All webhooks will contain the following set of request headers:
}
```

The `Sentry-Hook-Resource` and `Sentry-Hook-Signature` are described below.
The `Content-Type` header identifies the media type of the payload as JSON format. The `Request-ID` header provides a unique identifier for tracking and debugging specific events.

### `Sentry-Hook-Resource`

This is the resource that triggered the action. The action will be in the payload. The possible resources are listed below:
This header lets you know which resource from the list below triggered an action:

- `installation`
- `event_alert`
Expand All @@ -45,9 +47,11 @@ This is the resource that triggered the action. The action will be in the payloa

### `Sentry-Hook-Signature`

A hash generated using your Client Secret and the request itself. Used to verify the authenticity of the request.
This header represents a cryptographic hash generated by your _Client Secret_. Its primary purpose is to make sure the request is authentic and comes from Sentry servers.

**Verifying the Signature**

#### Verifying the Signature
The below code snippet lets you validate the signature with the event payload.

```javascript
const crypto = require("crypto");
Expand Down Expand Up @@ -139,3 +143,9 @@ All webhook requests have some common elements.
- [Comments](/product/integrations/integration-platform/webhooks/comments/)

- [Errors](/product/integrations/integration-platform/webhooks/errors/)

## Developing and Testing Webhooks

If you’d like to test webhook configuration and look at payloads before starting development, an HTTP catch-all service that provides a designated URL where you can receive HTTP payloads and inspect the JSON event payload can come in handy. After you’ve reviewed the relevant event payloads, you can begin development.

To make testing and debugging webhooks faster and easier, you can create local tunnels to get incoming webhook requests from Sentry to your local machine. There are various tools that let you pick a port or address (such as 3000 or 8080) to be tunneled, and then provide you with a temporary public URL that forwards requests to your local server.

1 comment on commit fd20673

@vercel
Copy link

@vercel vercel bot commented on fd20673 Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

docs.sentry.io
sentry-docs-git-master.sentry.dev
sentry-docs.sentry.dev

Please sign in to comment.