# Webhook

> Base URL: `https://pos.pages.fm/api/v1`. Xác thực bằng tham số truy vấn `api_key`.

## Cấu hình Webhook

`PUT /shops/{SHOP_ID}`

Cấu hình thiết lập webhook. Vào **Cấu hình -> Nâng cao -> Kết nối bên thứ 3 -> Webhook/API** để cấu hình:
- Webhook URL (Bắt buộc)
- Email thông báo lỗi
- Request Headers
- Loại webhook: `orders`, `customers`, `products`, `variations_warehouses`, hoặc `auto_call`

## Các Loại Phản Hồi Webhook

Khi webhook được bật, hệ thống gửi yêu cầu POST đến URL đã cấu hình. Schema phản hồi:

- **`orders`**: Xem schema [WebhookOrderResponse](#model/WebhookOrderResponse)
- **`customers`**: Xem schema [WebhookCustomerResponse](#model/WebhookCustomerResponse)
- **`products`**: Xem schema [WebhookProductResponse](#model/WebhookProductResponse)
- **`variations_warehouses`**: Xem schema [WebhookInventoryResponse](#model/WebhookInventoryResponse)
- **`auto_call`**: Xem schema [WebhookAutoCallResponse](#model/WebhookAutoCallResponse)

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |

### Nội dung yêu cầu

Thông tin yêu cầu chứa thông tin cần cập nhật

- `shop` (object, required): 
  - `webhook_enable` (boolean): Bật/Tắt Webhook
  - `webhook_url` (string (uri)): Link URL
  - `webhook_email` (string (email)): Email thông báo lỗi
  - `webhook_types` (string[]): Dữ liệu Webhook
  - `webhook_partner` (string): Đối tác
  - `webhook_headers` (object): Header Webhook

```json
{
  "shop": {
    "webhook_enable": true,
    "webhook_url": "https://test.com",
    "webhook_email": "1234@gmail.com",
    "webhook_types": [
      "orders",
      "customers",
      "variations_warehouses"
    ],
    "webhook_partner": "",
    "webhook_headers": {
      "X-API-KEY": "elqsF9ERiFWGacWQO9Gg5XC4kXojot"
    }
  }
}
```

### Phản hồi

- `200` Success (object)

```json
{
  "success": true
}
```
