---
url: /en/paas/user-notify.md
description: >-
  Documents how to configure user notification webhooks in CNB PAAS, allowing
  the system to send event-triggered messages (PR reviews, issue updates,
  repository and organization changes) to a callback URL.
---
## Overview

`Cloud Native Build` supports users to subscribe to system events
and push notification messages to a configured callback URL.

## Workflow

```mermaid
  sequenceDiagram
    participant Cloud Native Build
    participant Notification Callback URL
    participant Third-party Messaging Service
    participant User to be notified
    Cloud Native Build->>Notification Callback URL: 1. send user notify message
    Notification Callback URL->>Third-party Messaging Service: 2. parse the message and send to message service
    Third-party Messaging Service->>User to be notified: 3. notify user and show the message
```

## Notification Configuration

After logging into the admin management platform,
click `Admin Console → System Hook Configuration → Create System Hook` to enter the configuration page.
![user\_notify\_settings](/images/admin-hook-setting.png)

The configuration parameters are as follows:

| Parameter Name | Type     | Required | Description                                                   |
| :------------: | :------: | :------: | :------------------------------------------------------------ |
| URL            | String   | Y        | Callback URL. Cloud Native Build will send notification messages here. |
| Type           | String   | Y        | Select `User Notification`                                    |
| Trigger        | String   | Y        | Subscribed event types, multiple selections supported          |
| Token          | String   | N        | Authorization token for the callback URL, optional            |

## Event Types

`Cloud Native Build` supports the following event types (not limited to):

* pull request
  * New comment
  * New assignee
  * New reviewer
  * Status change
  * New review
* issue
  * New comment
  * New assignee
  * Status change
* Repository
  * Archive
  * Delete
  * Transfer
  * Member role change
* Organization
  * Transfer
  * Member role change
* User
  * @user

## Notification Message Structure

### Notification Header

* `Content-Type`: `application/json;charset=utf-8`
* `X-CNB-Event`: `System Hook`, identifies the notification message event
* `X-CNB-Token`: If an authorization token is configured (see `Notification Configuration`), this field will be included

### Notification Body

```json
{
  "touser": "UserID1|UserID2|UserID3", 
  "msgtype": "text", 
  "text": {
    "content": "There is a new PR to be processed"
  }
}
```

Parameter descriptions:

| Parameter Name | Type     | Required | Description                                                      |
| :------------: | :------: | :------: | :--------------------------------------------------------------: |
| touser         | String   | Y        | List of member IDs to receive the message (separated by `\|`, up to 1000) |
| msgtype        | String   | Y        | Message type, fixed as: text                                    |
| content        | String   | Y        | Message content, up to 2048 bytes                               |

### Notification Message Example

Taking Pull Request review as an example, when a reviewer approves the PR, the following notification is sent:

```text
admin1 approved PR #1

feat: init
https://cnbprod.alpha.qq.com/test/test-repo/-/pulls/1
```

Request body content:

```json
{
  "touser": "123",
  "msgtype": "text",
  "text": {
    "content": "admin1 approved PR #1\n\nfeat: init\ncnbprod.alpha.qq.com/test/test-repo/-/pulls/1"
  }
}
```
