# Webhooks (Admin)

To start receiving commerce service webhooks in your application, you must first create some webhook configuration inside your company.

Basically, that configurations defines what is the endpoint that commerce service should call when some event happens and it defines also the signature key that the endpoint should use to validate the request.

{% hint style="info" %}
To understand how to verify webhook signatures and what are the available webhook events, please visit [Webhooks Page](../webhooks).
{% endhint %}

<details>

<summary>Webhook Configuration Model (Example)</summary>

```json
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "createdAt": "2022-11-04T13:36:47.665Z",
  "updatedAt": "2022-11-04T13:36:47.665Z",
  "companyId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "company": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "createdAt": "2022-11-04T13:36:47.665Z",
    "updatedAt": "2022-11-04T13:36:47.665Z",
    "name": "string"
  },
  "webhookUrl": "https://mydomain.hook.me",
  "signatureKey": "string",
  "maxRetries": 5,
  "disabled": false
}
```

</details>

## Service Methods

### Creates a new Webhook Configuration inside a company

{% hint style="info" %}
The signature key could not be changed and is automatically generated. Each configuration has it owns signature key. To be safe, you must ensure that your endpoint will accept request only from our service by checking the signature.
{% endhint %}

Rest API reference:

{% openapi src="https://commerce.pixway.io/sdk-json" path="/admin/companies/{companyId}/webhooks-configurations" method="post" %}
[https://commerce.pixway.io/sdk-json](https://commerce.pixway.io/sdk-json)
{% endopenapi %}

### Lists all webhook configurations from some company

Rest API reference:

{% openapi src="https://commerce.pixway.io/sdk-json" path="/admin/companies/{companyId}/webhooks-configurations" method="get" %}
[https://commerce.pixway.io/sdk-json](https://commerce.pixway.io/sdk-json)
{% endopenapi %}

### Gets some webhook configuration of a company by ID

Rest API reference:

{% openapi src="https://commerce.pixway.io/sdk-json" path="/admin/companies/{companyId}/webhooks-configurations/{configurationId}" method="get" %}
[https://commerce.pixway.io/sdk-json](https://commerce.pixway.io/sdk-json)
{% endopenapi %}

### Updates some company webhook configuration

Rest API reference:

{% openapi src="https://commerce.pixway.io/sdk-json" path="/admin/companies/{companyId}/webhooks-configurations/{configurationId}" method="patch" %}
[https://commerce.pixway.io/sdk-json](https://commerce.pixway.io/sdk-json)
{% endopenapi %}

### Enables some disabled company webhook configuration

Rest API reference:

{% openapi src="https://commerce.pixway.io/sdk-json" path="/admin/companies/{companyId}/webhooks-configurations/{configurationId}/enable" method="patch" %}
[https://commerce.pixway.io/sdk-json](https://commerce.pixway.io/sdk-json)
{% endopenapi %}

### Disabled some enabled company webhook configuration

Rest API reference:

{% openapi src="https://commerce.pixway.io/sdk-json" path="/admin/companies/{companyId}/webhooks-configurations/{configurationId}/disable" method="patch" %}
[https://commerce.pixway.io/sdk-json](https://commerce.pixway.io/sdk-json)
{% endopenapi %}

### Lists all events sent by some webhook configuration

{% hint style="info" %}
With that sent webhook event entity, you can also know the result of the request and the last result that your configured endpoint returned to the commerce service.
{% endhint %}

Rest API reference:

{% openapi src="https://commerce.pixway.io/sdk-json" path="/admin/companies/{companyId}/webhooks-configurations/{configurationId}/webhooks" method="get" %}
[https://commerce.pixway.io/sdk-json](https://commerce.pixway.io/sdk-json)
{% endopenapi %}

### Gets some webhook event sent by some webhook configuration by ID

Rest API reference:

{% openapi src="https://commerce.pixway.io/sdk-json" path="/admin/companies/{companyId}/webhooks-configurations/{configurationId}/webhooks/{webhookId}" method="get" %}
[https://commerce.pixway.io/sdk-json](https://commerce.pixway.io/sdk-json)
{% endopenapi %}
