# Add Webhook

## How this example works

Webhooks in Open Loyalty enable automated interactions by sending HTTP requests to specified URLs when certain events occur within the system. This feature allows for real-time notifications and integrations with external systems. For example, when a customer registers or a transaction is created, a webhook can notify a designated URL, triggering predefined actions such as updating records or sending notifications.

To receive webhooks for the following steps, we are going to set up two webhooks in this example.

***

## Try yourself <a href="#to-try-it-yourself" id="to-try-it-yourself"></a>

* Input the previous saved [token](https://help.openloyalty.io/technical-guide/getting-started-guide/authentication) and [storeCode](https://help.openloyalty.io/technical-guide/member-registartion-configuration#to-try-it-yourself) in the request header
* Retrieve a list of available webhook events\
  Endpoint: `GET /api/{storeCode}/webhook/event`
* Get the URL, where the webhooks are supposed to be sent to.
* Add these three webhooks\
  Endpoint: `POST /api/{storeCode}/webhook/subscription`

  ```
  {
    "webhookSubscription": {
      "eventName": "CustomerRegistered",
      "url": "string" // your specified URL
    }
  }
  ```

  <br>

  ```
  {
    "webhookSubscription": {
      "eventName": "CustomerRegistered",
      "url": "string" // your specified URL
    }
  }
  ```

  <br>

  ```
  {
    "webhookSubscription": {
      "eventName": "MemberAchievementProgressWasChanged",
      "url": "string" // your specified URL
    }
  }
  ```

***

## Endpoints used

{% openapi src="<https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20(1).json>" path="/api/{storeCode}/webhook/event" method="get" %}
[openapi-5.61.0 (1).json](https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20\(1\).json)
{% endopenapi %}

{% openapi src="<https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20(1).json>" path="/api/{storeCode}/webhook/subscription" method="post" %}
[openapi-5.61.0 (1).json](https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20\(1\).json)
{% endopenapi %}

***

## More resources

For a detailed overview and description of the webhooks, please refer to this article:

{% content-ref url="<https://app.gitbook.com/s/cNVX03KZzmrGwJihLiEx/main-features/webhooks>" %}
[Webhooks](https://app.gitbook.com/s/cNVX03KZzmrGwJihLiEx/main-features/webhooks)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.openloyalty.io/technical-guide/getting-started-guide/add-webhook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
