**版本：202201**

# 创建 Webhook

**POST** `/openapi/2022-01/webhooks`

创建包含通知 URL、事件名称和格式的 Webhook。

## 请求

**application/json**

**请求体 | 示例**

**请求体**

- `address` string (required)

  Webhook notification URL, e.g. `https://example.com/webhook`
- `topic` string (required)

  Event name, e.g. `orders/cancelled`

```json
{
  "address": "string",
  "topic": "string"
}
```

## 响应

**200 | 422**

200

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `webhook` object

  - `id` string

    **示例：** `37593634-c272-4ed5-9096-1a4f1212125e`
  - `address` string

    **示例：** `https://abc.com`
  - `topic` string

    **示例：** `order/create`
  - `created_at` string

    **示例：** `2018-08-26T06:50:00Z`
  - `updated_at` string

    **示例：** `2018-08-26T06:50:00Z`
  - `format` string

    **示例：** `json`

```json
{
  "webhook": {
    "id": "37593634-c272-4ed5-9096-1a4f1212125e",
    "address": "https://abc.com",
    "topic": "order/create",
    "created_at": "2018-08-26T06:50:00Z",
    "updated_at": "2018-08-26T06:50:00Z",
    "format": "json"
  }
}
```

```json
{
  "webhook": {
    "id": "37593634-c272-4ed5-9096-1a4f1212125e",
    "address": "https://abc.com",
    "topic": "order/create",
    "created_at": "2018-08-26T06:50:00Z",
    "updated_at": "2018-08-26T06:50:00Z",
    "format": "json"
  }
}
```

422

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `errors` object

  - `address` string[]
  - `topic` string[]

```json
{
  "errors": {
    "address": [
      "can't be blank"
    ],
    "topic": [
      "can't be blank"
    ]
  }
}
```

```json
{
  "errors": {
    "address": [
      "can't be blank",
      "is invalid"
    ],
    "topic": [
      "can't be blank"
    ]
  }
}
```
