# 事件通知

{% hint style="info" %}
遇到 API 接入问题时，可登录 [Eva](https://www.atriptech.com/) 寻求帮助。
{% endhint %}

当 Atlas 检测到影响订单的运营事件时，使用这个 webhook。

### 触发时机

以下场景会触发事件通知：

* `email.schedulechange`
* `order.schedulechange`
* `abnormal.cancelled`

### 收到后建议处理

收到事件后，建议：

* 先识别事件类型
* 判断是否需要旅客进一步处理
* 必要时通知受影响旅客
* 结合事件查询或订单查询继续排查

### 推送方式

Atlas 会向你已注册的 webhook 地址发起 `POST` 请求。

### 建议优先读取的字段

* `type`
* `notificationId`
* `status`
* `data.orderNo`

然后再根据 `type` 读取对应的事件字段。

### 事件类型

#### `email.schedulechange`

Atlas 收到了航司发出的航变邮件。\
重点看 `data.emailSubject` 和 `data.emailLink`。

#### `order.schedulechange`

Atlas 提供了结构化航变数据。\
重点看航段数组和 `scheduleChangeType`。

#### `abnormal.cancelled`

Atlas 检测到异常取消。\
重点看订单号和取消相关字段。

### 说明

* `status` 表示事件确认状态
* `emailLink` 是临时链接，必要时请尽快保存内容
* 依赖这些通知前，请先完成 webhook 地址注册

### 注册请求示例

```json
{
  "cid": "XXXXXXXX",
  "url": "https://xxx.com/xxxx"
}
```

{% tabs %}
{% tab title="字段说明" %}
**cid**

* **类型：** String
* **是否必填：** 是
* **说明：** 用于跟踪请求的客户唯一标识。

**type**

* **类型：** String
* **是否必填：** 是
* **说明：** 事件类型。
* **可选值：**
  * `email.schedulechange`：邮件航变通知
  * `order.schedulechange`：API 航变通知
  * `abnormal.cancelled`：未对账取消

**notificationId**

* **类型：** String
* **是否必填：** 是
* **说明：** 通知事件唯一标识。

**status**

* **类型：** Integer
* **是否必填：** 是
* **说明：** 事件状态。
* **可选值：**
  * `0`：未确认
  * `1`：已确认

**data.orderNo**

* **类型：** String
* **是否必填：** 是
* **说明：** 订单唯一编号。

**data.emailSubject**

* **类型：** String
* **说明：** 邮件航变场景下的邮件主题。

**data.emailLink**

* **类型：** String (URL)
* **说明：** 邮件详情链接。通常只有短时效。
  {% endtab %}

{% tab title="示例" %}
**邮件航变通知**

```json
{
    "cid":"xxxxxxxxxx",
    "type":"email.schedulechange",
    "notificationId":"20230323113246035DNIDD",
    "status":0,
    "data":{
        "orderNo":"TESTS20230323103458265",
        "emailSubject":"IMPORTANT: Flight delay notice. Confirmation Code KDK7QG",
        "emailLink":"https://theatlas/#/email-detail/4378270"
    }
}
```

**API 航变通知**

```json
{
  "cid": "xxxxxxxxxx",
  "data": {
    "orderNo": "XCEWF20221203094515954",
    "previousSegs": [],
    "revisedSegs": [],
    "scheduleChangeType": 1
  },
  "notificationId": "20230424050252711WZDMB",
  "status": 0,
  "type": "order.schedulechange"
}
```

**未对账取消**

```json
{
  "cid": "xxxxxxxxxx",
  "data": {
    "orderNo": "RQWUV20230617185232880",
    "vendorRefundInformation": "FULLY"
  },
  "notificationId": "20230906014000568DRLNX",
  "status": 0,
  "type": "abnormal.cancelled"
}
```

{% endtab %}
{% endtabs %}

### 相关页面

* [Webhook 注册与事件](https://resources.atriptech.com/api-wen-dang/api-can-kao/webhook-yu-shi-jian-api/webhook-zhu-ce-yu-shi-jian)
* [事件查询](https://resources.atriptech.com/api-wen-dang/ji-cheng-zhi-nan/webhook-gai-lan/shi-jian-cha-xun)
* [航变通知](https://resources.atriptech.com/api-wen-dang/ji-cheng-zhi-nan/webhook-gai-lan/schedule-change-notification)
* [邮件通知](https://resources.atriptech.com/api-wen-dang/ji-cheng-zhi-nan/webhook-gai-lan/email-notification)
