> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goldsky.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send subgraph-driven webhooks

> Receive real-time HTTP POST requests based on  your subgraphs.

Power Discord notifications, back-end operations, orderbooks, and more with webhooks for subgraphs. Receive real-time HTTP POST requests to your backends whenever a subgraph indexes a new event. Every project has webhooks enabled by default for free.

Let's speed-run a simple example of a webhook. We'll create a webhook that sends a POST request to a URL of your choice whenever a trade occurs on the X2Y2 exchange.

## What you'll need

1. One or more subgraphs in your project - this can be from community subgraphs, a deployed subgraph, or a [no-code subgraph](/subgraphs/guides/create-a-no-code-subgraph).

2. A webhook handler; making a fully functional webhook handler is out of scope for this walkthrough so we'll be using a test platform called [Webhook.site](https://webhook.site/).

## Walkthrough

<Steps>
  <Step title="Deploy subgraph">
    Use Messari's [x2y2](https://thegraph.com/hosted-service/subgraph/messari/x2y2-ethereum) subgraph to the x2y2 exchange.

    ```shell theme={null}
    > goldsky subgraph deploy x2y2/v1 --from-ipfs-hash Qmaj3MHPQ5AecbPuzUyLo9rFvuQwcAYpkXrf3dTUPV8rRu
    Deploying Subgraph:
     ✔ Downloading subgraph from IPFS (This can take a while)
     ✔ Validating build path
     ✔ Packaging deployment bundle from /var/folders/p5/7qc7spd57jbfv00n84yzc97h0000gn/T/goldsky-deploy-Qmaj3MHPQ5AecbPuzUyLo9rFvuQwcAYpkXrf3dTUPV8rRu
    ```
  </Step>

  <Step title="Create webhook handler">
    Let's use a pre-made webhook handler by going to [webhook.site](https://webhook.site) and copying the URL. It may look like something like `https://webhook.site/<YOUR-UNIQUE-WEBHOOK-SITE-ID>`

    <Info>
      Don't use format `https://webhook.site/#!/<YOUR-UNIQUE-WEBHOOK-SITE-ID>`
    </Info>

    Any new webhook can be sent to this URL and we'll be able to see and inspect the request body.
  </Step>

  <Step title="Create webhook">
    Create a webhook to receive x2y2 trades.

    ```shell theme={null}
    > goldsky subgraph webhook create x2y2/v1 --name x2y2-trade-webhook --entity trade --url https://webhook.site/<YOUR-UNIQUE-WEBHOOK-URL>
    ✔ Creating webhook

    Webhook 'x2y2-trade-webhook' created.
    Make sure calls to your endpoint have the following value for the 'goldsky-webhook-secret' header: whs_01GNV4RMJCFVH14S4YAFW7RGQK
    ```

    A secret will be generated for you to use in your webhook handler. This secret is used to authenticate the webhook request. You can ignore it for the purposes for this speed run.
  </Step>

  <Step title="Test webhook">
    Inspect the webhook.site URL (or your custom handler) again, you should see events start to stream in.
  </Step>
</Steps>

Can't find what you're looking for? Reach out to us at [support@goldsky.com](mailto:support@goldsky.com) for help.
