---
description: >-
  REST Hooks are a way to implement Webhooks. The REST hooks are used to
  subscribe for a certain event through our API and receive back the information
  you have subscribed for.
---

# 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;

![](https://1500209443-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lr8LbRfBsbV0y6ZopMS%2F-MTLJVH_FM6MaC133Sk6%2F-MTLJcVRMaOTQwWyDR10%2Fimage.png?alt=media\&token=d21706c5-8409-415e-ac9a-f9eeab95e024)

#### 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

![](https://1500209443-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lr8LbRfBsbV0y6ZopMS%2F-MQSMYwSfbXAswhMe7GD%2F-MQSPWyh0TrvtV_40XR6%2Frestunsub.png?alt=media\&token=919e0026-a4f5-4194-ac10-669bec0e0c72)

