# REST Hooks

Currently we provide 4 events to which you can subscribe and receive information when something has occurred.

| Subscription name  | Description                                                                                                     |
| ------------------ | --------------------------------------------------------------------------------------------------------------- |
| New\_Order         | <p></p><p>When a new order is created in Vendisto, the order and order line data is sent to the subscriber.</p> |
| New\_Product       | When a new product is created in Vendisto, the product data is sent to the subscriber.                          |
| New\_NewsItem      | When a new news item is created in Vendisto, the news item data is sent to the subscriber.                      |
| New\_Customer      | When a new customer is created in Vendisto, the customer data is sent to the subscriber.                        |
| Deleted\_Product   | When a product is deleted in Vendisto, the product id, number and status will be sent to the subscriber.        |
| Suspended\_Product | When a product is suspended is Vendisto, the product id, number and status will be sent to the subscriber.      |

{% hint style="warning" %}
The New\_Product event is not for products created through the Vendisto UI, but for the new ones imported using the Simplified Article Import!
{% endhint %}

{% hint style="info" %}
Use the subscription name as an event\_type name!
{% endhint %}

## How to use REST Hooks?

In order to use the REST hooks you first must create generate a token using our [Application management](https://app.gitbook.com/@shoxl/s/shoxl/vendisto-settings/application-management) section in the Settings of Vendisto. This way you can use the token to authenticate when making requests to the Vendisto API.&#x20;

Then, there are two possible scenarios when using the REST hooks. You can either subscribe or unsubscribe to an event.&#x20;

### **Subscribe**&#x20;

**Endpoint url: \[POST]** api-{shopUrl}/webhooks/subscribe - for more info refer to the webhooks section of the swagger documentation of the API at api-{shopUrl}/swagger.

You must provide two fields in the request body:

1. **The target\_url** - to which we will send the data when the event occurs
2. **The event\_type**: New\_Order, New\_Customer, New\_NewsIte&#x6D;*,* New\_Product

{% hint style="warning" %}
The response of this request will contain the subscription id, event\_type and target\_url. You should store this subscription id because you will need it in order to unsubscribe from the event.
{% endhint %}

### **Unsubscribe**

**Endpoint url: \[DELETE]** api-{shopUrl}/webhooks/unsubscribe/{subscriptionId} - for more info refer to the webhooks section of the swagger documentation of the API at api-{shopUrl}/swagger.

You must provide the subscription id as a url parameter.&#x20;

{% hint style="warning" %}
To both requests you should add either Authorization or x-api-key header with value - Bearer {token}!
{% endhint %}

{% hint style="warning" %}
Be aware to set the body of the subscribe request as Json and not as Text. In the screenshot below you can see how JSON is selected on top right.
{% endhint %}

## Example of subscribe and unsubscribe requests

### Subscribe&#x20;

![](/files/-MTLJcVRMaOTQwWyDR10)

#### Event fired response

```
"orderWithOrderLines": {
      "OrderLines": [
        {
          "OrderLineId": "b8b549f5-39c7-418f-9167-66fe1ab93044",
          "OrderId": "b1baa92f-e1cc-4ac4-8a1f-6d8cafbb2b55",
          "Position": 1,
          "ArticleId": "bf095e2b-8658-4404-8b5c-12bbb69b340b",
          "ArticleNumber": "656516512651",
          "Name": "10,8 V CC300 Glas- en tegelsnijder - Accu-Glas-/tegelsnijder 10,8V CC300DWE - 2x1,3Ah",
          "Quantity": 3,
          "PriceWithoutTax": 9.91,
          "Tax": 2.08,
          "TaxPercentage": 21,
          "TotalPriceWithoutTax": 29.73,
          "IsTaxIncludedInPrice": true,
          "StockStatus": "NotApplicable",
          "Type": "Product"
        },
        {
          "OrderLineId": "12ceab82-c20a-43ac-9505-4cbcfb174f3e",
          "OrderId": "b1baa92f-e1cc-4ac4-8a1f-6d8cafbb2b55",
          "Position": 2,
          "ArticleId": "a9ea68bd-d62d-4406-939c-12c69994fa7c",
          "ArticleNumber": "08101043",
          "Name": "10,8 V Accu - Accu 10,8V Li-ion 1,3Ah BL1013",
          "Quantity": 1,
          "PriceWithoutTax": 20.66,
          "Tax": 0,
          "TotalPriceWithoutTax": 20.66,
          "IsTaxIncludedInPrice": false,
          "StockStatus": "NotApplicable",
          "Type": "Product"
        }
      ],
      "OrderId": "b1baa92f-e1cc-4ac4-8a1f-6d8cafbb2b55",
      "OrderNumber": "000508",
      "DeliveryMethod": "Delivery",
      "PaymentMethod": "Ideal",
      "Gender": "Undefined",
      "FirstName": "Aleksandar",
      "MiddleName": "Georgiev",
      "LastName": "Georgiev",
      "StreetAddress1": "Wattstraat 17",
      "PostalCode": "5621AG",
      "City": "Eindhoven",
      "Country": "The Netherlands",
      "UseSeparateDeliveryAddress": false,
      "DeliveryFirstName": "Aleksandar",
      "DeliveryMiddleName": "Georgiev",
      "DeliveryLastName": "Georgiev",
      "DeliveryStreetAddress1": "Wattstraat 17",
      "DeliveryPostalCode": "5621AG",
      "DeliveryCity": "Eindhoven",
      "DeliveryCountry": "The Netherlands",
      "PhoneNumber": "0657444295",
      "MobilePhoneNumber": "0657444295",
      "EmailAddress": "test@gmail.com",
      "Created": "2021-01-07T14:56:19.163Z",
      "TotalPriceWithoutTax": 50.39,
      "TotalPrice": 56.63,
      "TotalTax": 6.24,
      "TotalPayed": 0,
      "TotalAmountOwed": 56.63,
      "TotalAmount": 56.63,
      "PaymentStatus": "Open",
      "InvoiceStatus": "None",
      "OrderDeliveryMode": "Stock",
      "OrderStatus": "Created",
      "CanBeUpdated": true,
      "CanBeConfirmed": true,
      "CanBePaid": true,
      "CanBeApproved": false,
      "CanBeProcessed": false
  }
  
```

### Unsubscribe

![](/files/-MQSPWyh0TrvtV_40XR6)


---

# 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://shoxl.gitbook.io/vendisto-user-guide/rest-hooks.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.
