# Webhooks

API endpoints for webhook servicing. It offers the possibility to read,
add, change and delete the registered webhooks. Furthermore, it offers
a list of notifications about invoked webhooks and their status.

The webhooks are HTTP calls, which send HTTPs calls to registered
subscribers if a specific event happens,

for example creating an order. Then the information, in JSON format, is
delivered to the defined URL.

```javascript

{
    "eshopId": 222651,
    "event": "order:create",
    "eventCreated": "2019-01-08T15:13:39+0100",
    "eventInstance": "2018000057"
}

```

The meaning of individual items:

* `eshopId` - number of the e-shop, where the event happened

* `event` - event which invoked the call (see code list
[Webhook event types](#section/code-lists/webhook-event-types))

* `eventCreated` - accurate time, when the event happened

* `eventInstance` - reference to a specified entity - according to the
context, order number, invoice number, product GUID, etc.

For more information about the function of webhooks, see
https://developers.shoptet.com/webhooks/.

## Overview of registered webhooks

 - [GET /api/webhooks](https://api.docs.shoptet.com/shoptet-api/openapi/webhooks/getoverviewofregisteredwebhooks.md): Returns the list of webhooks, registered by the specific addon for a
single e-shop. It is therefore bound to the specific installation.

The addon does not have any access to another addon (not even for the
same e-shop, or two addons from the same developer).

## Registration of new webhook

 - [POST /api/webhooks](https://api.docs.shoptet.com/shoptet-api/openapi/webhooks/registernewwebhook.md): Registers the webhook. For a single event (event, for example
order:create) ONLY ONE URL can be registered.

If you try to enter the webhook for an event that already exists, you
will
 receive error 422 with message Webhook already exists for this event. Successful creation (registration) of webhook is signaled by code 201. The endpoint returns the info
on the created webhook. One of the items is id, which is assigned to
the webhook and is used for its identification

upon change or deletion.


The supported event can be found in code list Webhook event types.


It is possible to enter up to 50 webhooks using a single call.

Please note that url cannot be longer than 2000 characters.

## Detail of registered webhooks

 - [GET /api/webhooks/{id}](https://api.docs.shoptet.com/shoptet-api/openapi/webhooks/getdetailofregisteredwebhooks.md): Shows the information about a single specific registered webhook.

## Update of existing webhook

 - [PATCH /api/webhooks/{id}](https://api.docs.shoptet.com/shoptet-api/openapi/webhooks/updateexistingwebhook.md): Modification of the existing webhook. The id of the webhook serves as
the identifier. Using just one call, only one webhook can be modified.


Please note that url cannot be longer than 2000 characters.

## Deletion of registered webhook

 - [DELETE /api/webhooks/{id}](https://api.docs.shoptet.com/shoptet-api/openapi/webhooks/deleteregisteredwebhook.md): Deletes the registered webhook, identified by means of id.

## Generating of signature key

 - [POST /api/webhooks/renew-signature-key](https://api.docs.shoptet.com/shoptet-api/openapi/webhooks/generatewebhooksignaturekey.md): The endpoint call does not require any body. The endpoint always
generates a new signature key

for calculating the digest mentioned in the HTTP header of the
notification – Shoptet-Webhook-Signature. The same key

is to be used during check after the receipt of notification. For more
information see https://developers.shoptet.com/webhooks/#signature

## Webhook notification

 - [GET /api/webhooks/notifications](https://api.docs.shoptet.com/shoptet-api/openapi/webhooks/getwebhooknotification.md): Returns the notification (invoking) list of webhooks and provides information about these. If you do not have 
a registered webhook, and the given event happens (for example creation of an order), the registered URLs are 
called. A notification about a call contains information about the webhook that requested the call, the URL 
called, the time, delivery status, number of delivery attempts and other information.


It is possible to request 7 days history of notification.

